public interface ILcdDataObject
A data object is a representation of some structured data. It is the fundamental component in the datamodel package.
A data object has one or more properties. For each of these properties, the data object can have one or more values. This interface provides access (both getter and setter) to these values. Note that the values can be primitive object (Strings, numbers, and so on) but also data objects themselves.
Each data object has a TLcdDataType
. This type defines the properties
that a data object has. The type also provides a method to create new instances.
ILcdModel
.
Consult the Introduction to the data modeling API for more information.Modifier and Type | Method and Description |
---|---|
TLcdDataType |
getDataType()
Returns the type of this data object.
|
Object |
getValue(String aPropertyName)
Convenience method that returns the value of the property with the given name.
|
Object |
getValue(TLcdDataProperty aProperty)
Returns the value of the given property.
|
boolean |
hasValue(String aPropertyName)
Indicates whether this data object has a value for the given property.
|
boolean |
hasValue(TLcdDataProperty aProperty)
Indicates whether this data object has a value for the given property.
|
void |
setValue(String aPropertyName,
Object aValue)
Convenience method that sets the value of the property with the given name.
|
void |
setValue(TLcdDataProperty aProperty,
Object aValue)
Sets the value of the given property for this data object.
|
TLcdDataType getDataType()
null
.Object getValue(TLcdDataProperty aProperty)
Returns the value of the given property.
If the property is a collection, the returned value will never be null. If the property has not been set, an empty collection of the appropriate type will be returned (Set, List or Map).
The property must not be null, and must be declared in the data object's type
or in one of its super types.
Otherwise an IllegalArgumentException
is thrown.
aProperty
- the property for which the value is to be returnedIllegalArgumentException
- if the property is not a property of the data object's typeNullPointerException
- if the property is nullObject getValue(String aPropertyName)
Convenience method that returns the value of the property with the given name.
If more than one property exists with the given name, the most specific property should be used (this is the property defined by the most specialized type in this object's data type hierarchy). SeegetValue(TLcdDataProperty)
for more information.aPropertyName
- the name of the property of which the value is to be returnedIllegalArgumentException
- if no such property existsNullPointerException
- if the property name is nullTLcdDataType.getProperty(String)
void setValue(TLcdDataProperty aProperty, Object aValue)
Sets the value of the given property for this data object. The implementation is allowed to throw an exception if the given value can't be set.
The given property must be declared in thedata object's type
or in one of its super types. In
other words, getDataType().getProperties().contains( aProperty ) should always be true.
Otherwise, the implementation should throw an IllegalArgumentException
.aProperty
- the property for which the value is to be setaValue
- the value to setIllegalArgumentException
- if the value can't be set.UnsupportedOperationException
- if this object is not editable.TLcdDataType.getProperty(String)
void setValue(String aPropertyName, Object aValue)
Convenience method that sets the value of the property with the given name.
If more than one property exists with the given name, the most specific property should be used (this is the property defined by the most specialized type in this object's data type hierarchy). SeesetValue(TLcdDataProperty, Object)
for more information.aPropertyName
- the name of the property of which the value is to be setaValue
- the value to setIllegalArgumentException
- if no such property existsUnsupportedOperationException
- if this object is not editable.boolean hasValue(TLcdDataProperty aProperty)
aProperty
is from the right data type
, and this instance has a value for it: returns true
aProperty
is from the right data type
, and this instance has no value for it: returns false
aProperty
is not from the right data type
: not allowed, you will get IllegalArgumentExceptionaProperty
is null
: not allowed, you will get NullPointerExceptionaProperty
- the property for which to return whether a value is present or not.true
if this data object has a value for the given property, false
otherwise.IllegalArgumentException
- if the property is not a property of the data object's typeboolean hasValue(String aPropertyName)
hasValue(TLcdDataProperty)
for more information.aPropertyName
- the name of the property for which to return whether a value is present
or not.true
if this data object has a value for the property with the given name,
false
otherwise.IllegalArgumentException
- if no such property exists