Package org.fastnate.generator.context
Interface AttributeAccessor
- All Superinterfaces:
AnnotatedElement
Offers access to a persistent attribute in an entity class.
Instances are created using one of the
AccessStyles.- Author:
- Tobias Liefke
-
Method Summary
Modifier and TypeMethodDescriptionDescribes how this attribute accesses the values below.Class<?> The class that declared this attribute.The actual field or method.The generic type of the accessed attribute.Class<?> The class that is the type of every object that contains this attribute.intThe combination ofModifiers.getName()The name of the accessed attribute.Class<?> getType()The type of the accessed attribute.<E,T> T getValue(E entity) Resolves the current value for the attribute on the given entity.<E,T> void setValue(E entity, T value) Sets a new value for the attribute on the given entity.Methods inherited from interface java.lang.reflect.AnnotatedElement
getAnnotation, getAnnotations, getAnnotationsByType, getDeclaredAnnotation, getDeclaredAnnotations, getDeclaredAnnotationsByType, isAnnotationPresent
-
Method Details
-
getAccessStyle
AccessStyle getAccessStyle()Describes how this attribute accesses the values below.- Returns:
- the type that has created this attribute accessor
-
getDeclaringClass
Class<?> getDeclaringClass()The class that declared this attribute.- Returns:
- the class that contains the attribute
-
getElement
AnnotatedElement getElement()The actual field or method.- Returns:
- the wrapped element of the attribute
-
getGenericType
Type getGenericType()The generic type of the accessed attribute.- Returns:
- the generic type of the field or the generic return type of the method
-
getImplementationClass
Class<?> getImplementationClass()The class that is the type of every object that contains this attribute. Eitherthe class that declared this attributeor a sub class. Used to resolve any generic type parameter ingetType().- Returns:
- the class where the scan of attributes started
-
getModifiers
int getModifiers()The combination ofModifiers.- Returns:
- the modifiers of the field or method
-
getName
String getName()The name of the accessed attribute.- Returns:
- the name (
decapitalizedif necessary)
-
getType
Class<?> getType()The type of the accessed attribute. If the type is a generic type, any type variable is resolved withgetImplementationClass().- Returns:
- the type of the field or the return type of the method
-
getValue
<E,T> T getValue(E entity) Resolves the current value for the attribute on the given entity.- Parameters:
entity- the entity to inspect- Returns:
- the value,
nullif entity isnull
-
setValue
<E,T> void setValue(E entity, T value) Sets a new value for the attribute on the given entity.- Parameters:
entity- the entity to inspectvalue- the new value
-