Interface ObjectMember
-
@API(status=EXPERIMENTAL) public interface ObjectMemberA pointer to a class member belonging to a certain object instance. Allows to read and modify the member's value in place.- Author:
- Simon Taddiken
- See Also:
ObjectTraversal
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.util.Optional<java.lang.Object>collectionParent()Ifparent()has been discovered in a supported collection type (array,Iterable,Collection,Map) this method returns the respective collection.default booleanhasTypeCompatibleTo(java.lang.Class<?> type)booleanisReadonly()booleanisWriteOnly()java.lang.Stringname()The canonical name of the member.java.lang.Objectparent()The object of which this is a direct child attribute.voidsetValue(java.lang.Object value)Sets the member's value to the respective value.java.lang.Objectvalue()Reads the member's value.java.lang.Class<?>valueType()The type of this member.
-
-
-
Method Detail
-
parent
java.lang.Object parent()
The object of which this is a direct child attribute.- Returns:
- Our parent.
-
collectionParent
java.util.Optional<java.lang.Object> collectionParent()
Ifparent()has been discovered in a supported collection type (array,Iterable,Collection,Map) this method returns the respective collection.Note that, during traversal, only the first occurrence of an object instance is taken into account. If the same object is once referenced in a collection and once directly, then depending on attribute discovery order, you might or might not encounter the one with available collection parent.
- Returns:
- Pointer to the collection in which
parent()has been discovered while traversing an object graph.
-
name
java.lang.String name()
The canonical name of the member.- Returns:
- The name.
-
hasTypeCompatibleTo
default boolean hasTypeCompatibleTo(java.lang.Class<?> type)
-
valueType
java.lang.Class<?> valueType()
The type of this member.- Returns:
- The type.
-
value
java.lang.Object value()
Reads the member's value. Whether reading the value is supported highly depends on the implementation. Implementations are advised to provide a best effort approach for determining the value without failure.If this member is
isWriteOnly()null is returned.- Returns:
- The value (may be null)
- Throws:
java.lang.UnsupportedOperationException- If reading the value fails.
-
setValue
void setValue(java.lang.Object value)
Sets the member's value to the respective value. Whether setting the value is supported highly depends on the implementation. If the member isisReadonly(), nothing happens.- Parameters:
value- The value to set (may be null)- Throws:
java.lang.UnsupportedOperationException- If setting the value is not possible.
-
isReadonly
boolean isReadonly()
-
isWriteOnly
boolean isWriteOnly()
-
-