Package io.microsphere.reflect
Class FieldDefinition
- java.lang.Object
-
- io.microsphere.reflect.ReflectiveDefinition
-
- io.microsphere.reflect.MemberDefinition<java.lang.reflect.Field>
-
- io.microsphere.reflect.FieldDefinition
-
- All Implemented Interfaces:
java.io.Serializable
public class FieldDefinition extends MemberDefinition<java.lang.reflect.Field>
The definition class ofField
- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
Field
, Serialized Form
-
-
Field Summary
-
Fields inherited from class io.microsphere.reflect.MemberDefinition
name
-
Fields inherited from class io.microsphere.reflect.ReflectiveDefinition
classLoader, className, deprecation, since
-
-
Constructor Summary
Constructors Constructor Description FieldDefinition(Version since, Deprecation deprecation, java.lang.String declaredClassName, java.lang.String fieldName)
FieldDefinition(Version since, java.lang.String declaredClassName, java.lang.String fieldName)
FieldDefinition(java.lang.String since, Deprecation deprecation, java.lang.String declaredClassName, java.lang.String fieldName)
FieldDefinition(java.lang.String since, java.lang.String declaredClassName, java.lang.String fieldName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
get(java.lang.Object instance)
Get the field valuejava.lang.String
getFieldName()
java.lang.reflect.Field
getResolvedField()
protected java.lang.reflect.Field
resolveMember()
Resolve themember
instance<T> T
set(java.lang.Object instance, T fieldValue)
Set the field value-
Methods inherited from class io.microsphere.reflect.MemberDefinition
equals, getDeclaredClass, getDeclaredClassName, getMember, getName, hashCode, isPresent, toString
-
Methods inherited from class io.microsphere.reflect.ReflectiveDefinition
getClassName, getDeprecation, getResolvedClass, getSince, isDeprecated
-
-
-
-
Constructor Detail
-
FieldDefinition
public FieldDefinition(@Nonnull java.lang.String since, @Nonnull java.lang.String declaredClassName, @Nonnull java.lang.String fieldName)
- Parameters:
since
- the 'since' versiondeclaredClassName
- the name of declared classfieldName
- the field name
-
FieldDefinition
public FieldDefinition(@Nonnull java.lang.String since, @Nullable Deprecation deprecation, @Nonnull java.lang.String declaredClassName, @Nonnull java.lang.String fieldName)
- Parameters:
since
- the 'since' versiondeprecation
- the deprecationdeclaredClassName
- the name of declared classfieldName
- the field name
-
FieldDefinition
public FieldDefinition(@Nonnull Version since, @Nonnull java.lang.String declaredClassName, @Nonnull java.lang.String fieldName)
- Parameters:
since
- the 'since' versiondeclaredClassName
- the name of declared classfieldName
- the field name
-
FieldDefinition
public FieldDefinition(@Nonnull Version since, @Nullable Deprecation deprecation, @Nonnull java.lang.String declaredClassName, @Nonnull java.lang.String fieldName)
- Parameters:
since
- the 'since' versiondeprecation
- the deprecationdeclaredClassName
- the name of declared classfieldName
- the field name
-
-
Method Detail
-
resolveMember
protected java.lang.reflect.Field resolveMember()
Description copied from class:MemberDefinition
Resolve themember
instance- Specified by:
resolveMember
in classMemberDefinition<java.lang.reflect.Field>
- Returns:
null
if can't be resolved
-
getFieldName
@Nonnull public java.lang.String getFieldName()
-
getResolvedField
@Nullable public java.lang.reflect.Field getResolvedField()
-
get
public <T> T get(java.lang.Object instance) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
Get the field value- Type Parameters:
T
- the field type- Parameters:
instance
- the instance- Returns:
null
- Throws:
java.lang.IllegalStateException
- if this Field object is enforcing Java language access control and the underlying field is inaccessible.java.lang.IllegalArgumentException
- if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof).
-
set
public <T> T set(java.lang.Object instance, T fieldValue)
Set the field value- Type Parameters:
T
- the field type- Parameters:
instance
- the instancefieldValue
- the value of field to be set- Returns:
- the previous value of the specified
Field
- Throws:
java.lang.IllegalStateException
- if this Field object is enforcing Java language access control and the underlying field is inaccessible.java.lang.IllegalArgumentException
- if the specified object is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof).
-
-