Class RootAccessor
- java.lang.Object
-
- org.soulwing.prospecto.api.association.AbstractAssociationManager<T,E>
-
- org.soulwing.prospecto.api.association.AbstractToOneAssociationManager<Object,Object>
-
- org.soulwing.prospecto.runtime.accessor.RootAccessor
-
- All Implemented Interfaces:
AssociationManager<Object,Object>
,ToOneAssociationManager<Object,Object>
,Accessor
public class RootAccessor extends AbstractToOneAssociationManager<Object,Object>
An accessor for a root object.- Author:
- Carl Harris
-
-
Method Summary
All Methods Instance Methods Concrete 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.protected Accessor
newAccessor(Class<?> type, String name)
protected Object
onGet(Object source)
protected void
onSet(Object target, Object value)
void
set(Object target, Object value)
Sets the property value.boolean
supports(AssociationDescriptor descriptor)
-
Methods inherited from class org.soulwing.prospecto.api.association.AbstractToOneAssociationManager
isSameAssociate
-
Methods inherited from class org.soulwing.prospecto.api.association.AbstractAssociationManager
newAssociate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.soulwing.prospecto.api.association.AssociationManager
newAssociate
-
Methods inherited from interface org.soulwing.prospecto.api.association.ToOneAssociationManager
isSameAssociate
-
-
-
-
Field Detail
-
INSTANCE
public static final Accessor INSTANCE
-
-
Method Detail
-
newAccessor
protected Accessor newAccessor(Class<?> type, String name) throws Exception
- Throws:
Exception
-
onGet
protected Object onGet(Object source) throws IllegalAccessException, InvocationTargetException
-
onSet
protected void onSet(Object target, Object value) throws IllegalAccessException, InvocationTargetException
-
getDataType
public Class<?> getDataType()
Description copied from interface:Accessor
Gets the declared data type of the property.- Returns:
- data type
-
getModelType
public Class<?> getModelType()
Description copied from interface:Accessor
Gets the model type in which the property is located- Specified by:
getModelType
in interfaceAccessor
- Returns:
- model type
-
getName
public String getName()
Description copied from interface:Accessor
Gets the name of the property.
-
getAccessType
public AccessType getAccessType()
Description copied from interface:Accessor
Gets the access type.- Specified by:
getAccessType
in interfaceAccessor
- Returns:
- access type
-
getSupportedModes
public EnumSet<AccessMode> getSupportedModes()
Description copied from interface:Accessor
Gets the supported access modes of this accessor.- Specified by:
getSupportedModes
in interfaceAccessor
- Returns:
- set of supported access modes
-
canRead
public boolean canRead()
Description copied from interface:Accessor
Tests whether this accessor can be called to read (get) a value.This is basically shorthand for
getAccessModes().contains(AccessMode.READ)
- Specified by:
canRead
in interfaceAccessor
- Returns:
true
if this accessor supportsAccessMode.READ
.
-
canWrite
public boolean canWrite()
Description copied from interface:Accessor
Tests whether this accessor can be called to write (set) a value.This is basically shorthand for
getAccessModes().contains(AccessMode.WRITE)
- Specified by:
canWrite
in interfaceAccessor
- Returns:
true
if this accessor supportsAccessMode.WRITE
.
-
forSubtype
public Accessor forSubtype(Class<?> subtype) throws Exception
Description copied from interface:Accessor
Creates a copy of this accessor for a particular subtype of the base type.- Specified by:
forSubtype
in interfaceAccessor
- Parameters:
subtype
- the subject subtype- Returns:
- accessor with same configuration, but with {!code subtype} as the new base type
- Throws:
Exception
-
get
public Object get(Object source) throws IllegalAccessException, InvocationTargetException
Description copied from interface:Accessor
Gets the property value.- Specified by:
get
in interfaceAccessor
- Specified by:
get
in interfaceToOneAssociationManager<Object,Object>
- Parameters:
source
- model object from which the property value is to be extracted- Returns:
- property value
- Throws:
IllegalAccessException
InvocationTargetException
-
set
public void set(Object target, Object value) throws IllegalAccessException, InvocationTargetException
Description copied from interface:Accessor
Sets the property value.- Specified by:
set
in interfaceAccessor
- Specified by:
set
in interfaceToOneAssociationManager<Object,Object>
- Parameters:
target
- model object into which the property value is to be injectedvalue
- property value to inject- Throws:
IllegalAccessException
InvocationTargetException
-
supports
public boolean supports(AssociationDescriptor descriptor)
- Specified by:
supports
in interfaceAssociationManager<Object,Object>
-
-