Interface Accessor
-
- All Superinterfaces:
AssociationManager<Object,Object>
,ToOneAssociationManager<Object,Object>
- All Known Implementing Classes:
RootAccessor
public interface Accessor extends ToOneAssociationManager<Object,Object>
An accessor for a property of a model.- Author:
- Carl Harris
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
canRead()
Tests whether this accessor can be called to read (get) a value.boolean
canWrite()
Tests whether this accessor can be called to write (set) a value.Accessor
forSubtype(Class<?> subtype)
Creates a copy of this accessor for a particular subtype of the base type.Object
get(Object source)
Gets the property value.AccessType
getAccessType()
Gets the access type.Class<?>
getDataType()
Gets the declared data type of the property.Class<?>
getModelType()
Gets the model type in which the property is locatedString
getName()
Gets the name of the property.EnumSet<AccessMode>
getSupportedModes()
Gets the supported access modes of this accessor.void
set(Object target, Object value)
Sets the property value.-
Methods inherited from interface org.soulwing.prospecto.api.association.AssociationManager
newAssociate, supports
-
Methods inherited from interface org.soulwing.prospecto.api.association.ToOneAssociationManager
isSameAssociate
-
-
-
-
Method Detail
-
getModelType
Class<?> getModelType()
Gets the model type in which the property is located- Returns:
- model type
-
getName
String getName()
Gets the name of the property.- Returns:
- property name
-
getAccessType
AccessType getAccessType()
Gets the access type.- Returns:
- access type
-
getSupportedModes
EnumSet<AccessMode> getSupportedModes()
Gets the supported access modes of this accessor.- Returns:
- set of supported access modes
-
canRead
boolean canRead()
Tests whether this accessor can be called to read (get) a value.This is basically shorthand for
getAccessModes().contains(AccessMode.READ)
- Returns:
true
if this accessor supportsAccessMode.READ
.
-
canWrite
boolean canWrite()
Tests whether this accessor can be called to write (set) a value.This is basically shorthand for
getAccessModes().contains(AccessMode.WRITE)
- Returns:
true
if this accessor supportsAccessMode.WRITE
.
-
getDataType
Class<?> getDataType()
Gets the declared data type of the property.- Returns:
- data type
-
forSubtype
Accessor forSubtype(Class<?> subtype) throws Exception
Creates a copy of this accessor for a particular subtype of the base type.- Parameters:
subtype
- the subject subtype- Returns:
- accessor with same configuration, but with {!code subtype} as the new base type
- Throws:
Exception
-
get
Object get(Object source) throws Exception
Gets the property value.- Specified by:
get
in interfaceToOneAssociationManager<Object,Object>
- Parameters:
source
- model object from which the property value is to be extracted- Returns:
- property value
- Throws:
Exception
-
-