Package io.jans.scim.model.scim2
Class CustomAttributes
- java.lang.Object
-
- io.jans.scim.model.scim2.CustomAttributes
-
public class CustomAttributes extends Object
A class used to store the values of custom attributes associated to a resource extension. This class is mainly targeted at users of Java client in order to specify/retrieve custom attributes.Use the
setAttributemethods to associate one (or several) values to an attribute, and use thegetValue/getValuesmethods to retrive those values when coming directly from service invocations.For both kind of operations (set/get) the data types used should ideally be consistent with the previously configured custom attributes at the Server. This allows your custom data to be successfully validated when sent to server, or to be correctly retrieved when reading a response.
For
photoortext, you may useString, fornumericsensible choices areIntegerorDouble, forbooleanuseBoolean, and fordateyou may useDate.See also:
BaseScimResource.addCustomAttributes(CustomAttributes)andBaseScimResource.getCustomAttributes(String).
-
-
Constructor Summary
Constructors Constructor Description CustomAttributes(String uri)Constructs an instance of this class to store the attribute values associated to an extension whose URI is supplied.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<String>getAttributeNames()Returns the names of all attributes currently part of this instance object.StringgetUri()Retrieves the URI to which thisCustomAttributesinstance is tied.<T> TgetValue(String name, Class<T> cls)Returns the value of a custom attribute as an instance of the specified type.<T> List<T>getValues(String name, Class<T> cls)Returns the values of a multi-valued custom attribute as aListof objects of the specified type.voidremove(String name)Removes an attribute (and associated value) from this objectvoidsetAttribute(String name, Boolean value)Sets the value of an attribute using aBoolean.voidsetAttribute(String name, Double value)Sets the value of an attribute using aDouble.voidsetAttribute(String name, Integer value)Sets the value of an attribute using anInteger.voidsetAttribute(String name, String value)Sets the value of an attribute using aString.voidsetAttribute(String name, Date value)Sets the value of an attribute using ajava.util.Date.voidsetAttribute(String name, List<?> values)Sets the value of an attribute using aListof objects.
-
-
-
Constructor Detail
-
CustomAttributes
public CustomAttributes(String uri)
Constructs an instance of this class to store the attribute values associated to an extension whose URI is supplied.- Parameters:
uri- A string denoting the URI of an existing extension
-
-
Method Detail
-
getUri
public String getUri()
Retrieves the URI to which thisCustomAttributesinstance is tied.- Returns:
- The URI as a String
-
getAttributeNames
public Set<String> getAttributeNames()
Returns the names of all attributes currently part of this instance object.- Returns:
- A Set of Strings
-
remove
public void remove(String name)
Removes an attribute (and associated value) from this object- Parameters:
name- The name of the attribute to remove. Use the exactly the same String as when the attribute was set
-
setAttribute
public void setAttribute(String name, String value)
Sets the value of an attribute using aString.- Parameters:
name- Name of attributevalue- A String object. Must be non-null, or else it won't be stored
-
setAttribute
public void setAttribute(String name, Boolean value)
Sets the value of an attribute using aBoolean.- Parameters:
name- Name of attributevalue- A Boolean object. Must be non-null, or else it won't be stored
-
setAttribute
public void setAttribute(String name, Double value)
Sets the value of an attribute using aDouble.- Parameters:
name- Name of attributevalue- A Double object. Must be non-null, or else it won't be stored
-
setAttribute
public void setAttribute(String name, Integer value)
Sets the value of an attribute using anInteger.- Parameters:
name- Name of attributevalue- An Integer object. Must be non-null, or else it won't be stored
-
setAttribute
public void setAttribute(String name, Date value)
Sets the value of an attribute using ajava.util.Date.- Parameters:
name- Name of attributevalue- A Date object. Must be non-null, or else it won't be stored
-
setAttribute
public void setAttribute(String name, List<?> values)
Sets the value of an attribute using aListof objects.- Parameters:
name- Name of attributevalues- A non-empty, non-null list of values.
-
getValues
public <T> List<T> getValues(String name, Class<T> cls)
Returns the values of a multi-valued custom attribute as aListof objects of the specified type. If you are not sure about the data type of the attribute, useStringfor type parameter T: in this casetoStringis used to generate a representation.- Type Parameters:
T- Type parameter for cls- Parameters:
name- The name of the custom attributecls- Specifies the type utilized to read the attribute values- Returns:
- null if the attribute is not known to this object, or if it was not possible to read any of its values
using the type provided. Otherwise, a list of values associated to the attribute is returned (when the attribute
is not multivalued, a singleton list is returned: use
getValueto get atomic values instead).
-
getValue
public <T> T getValue(String name, Class<T> cls)
Returns the value of a custom attribute as an instance of the specified type. If you are not sure about the data type of the attribute, useStringfor type parameter T: in this casetoStringis used to generate a representation.- Type Parameters:
T- Type parameter for cls- Parameters:
name- The name of the custom attributecls- Specifies the type utilized to read the attribute value- Returns:
- null if the attribute is not known to this object, or if it was not possible to read its value using the
type provided. Otherwise, the value associated to the attribute is returned (when the attribute is multivalued,
only the first value found is taken into account: use
getValuesto get all values).
-
-