Interface Attribute
-
- All Known Subinterfaces:
BooleanAttribute
,DateAttribute
,MultiValueListAttribute
,NumericAttribute
,ScriptAttribute
,SingleValueListAttribute
,StringAttribute
public interface Attribute extends Resource
Abstract super class for attributes
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description NamedResourceReference
getAsset()
Returns the asset this attribute belongs to.NamedResourceReference
getType()
Returns the attribute type for this attribute.Object
getValue()
Returns the value of this attribute.<T> T
getValueAs(Class<T> clazz)
Returns the value of this attribute casted to the class required by the parameter.String
getValueAsString()
Returns the value of this attribute represented as aString
.-
Methods inherited from interface Resource
getCreatedBy, getCreatedOn, getLastModifiedBy, getLastModifiedOn, getResourceType, isSystem
-
-
-
-
Method Detail
-
getType
NamedResourceReference getType()
Returns the attribute type for this attribute.- Returns:
- the attribute type for this attribute
-
getAsset
NamedResourceReference getAsset()
Returns the asset this attribute belongs to.- Returns:
- the asset this attribute belongs to
-
getValue
Object getValue()
Returns the value of this attribute. Class of the returned object depends on the type of the attribute. Following list presents class of the value depending on the kind of the attribute- kind:
NumericAttribute
-> value Class:Double
- kind:
ScriptAttribute
-> value Class:String
- kind:
SingleValueListAttribute
-> value Class:String
- kind:
DateAttribute
-> value class:Long
- kind:
StringAttribute
-> value class:String
- kind:
BooleanAttribute
-> value class:Boolean
- kind:
MultiValueListAttribute
-> value class:List
ofString
When retrieving attributes of a known kind it's safe to cast the value to the required class or use
getValueAs(Class)
method passing the correct class of the attribute value. To dynamically check the kind of attribute it is possible to i.e.:if(attribute instanceof NumericAttribute) { Double value = attribute.getValueAs(Double.class); }
if(attribute.getType().getResourceType() == NumericAttribute) { Double value = attribute.getValueAs(Double.class); }
- Returns:
- the value of this attribute
- kind:
-
getValueAs
<T> T getValueAs(Class<T> clazz)
Returns the value of this attribute casted to the class required by the parameter. Class of the returned object depends on the type of the attribute. Following list presents class of the value depending on the kind of the attribute- kind:
NumericAttribute
-> value Class:Double
- kind:
ScriptAttribute
-> value Class:String
- kind:
SingleValueListAttribute
-> value Class:String
- kind:
DateAttribute
-> value class:Long
- kind:
StringAttribute
-> value class:String
- kind:
BooleanAttribute
-> value class:Boolean
- kind:
MultiValueListAttribute
-> value class:List
ofString
When retrieving attributes of a known kind it's safe to cast the value to the required class or use
getValueAs(Class)
method passing the correct class of the attribute value. To dynamically check the kind of attribute it is possible to i.e.:if(attribute instanceof NumericAttribute) { Double value = attribute.getValueAs(Double.class); }
if(attribute.getType().getResourceType() == NumericAttribute) { Double value = attribute.getValueAs(Double.class); }
- Returns:
- the value of this attribute
- kind:
-
getValueAsString
String getValueAsString()
Returns the value of this attribute represented as aString
. Values ofMultiValueListAttribute
are represented as a ';' separatedString
- Returns:
- the value of this attribute as a
String
-
-