Package org.apache.juneau.reflect
Class FieldInfo
java.lang.Object
org.apache.juneau.reflect.FieldInfo
- All Implemented Interfaces:
- Comparable<FieldInfo>
Lightweight utility class for introspecting information about a field.
 
See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionPerforms an action on this object if the specified predicate test passes.Attempts to callx.setAccessible(and quietly ignores security exceptions.true )int<T> TReturns the field value on the specified object.<A extends Annotation>
 AgetAnnotation(Class<A> type) Returns the specified annotation on this field.<A extends Annotation>
 AgetAnnotation(AnnotationProvider annotationProvider, Class<A> type) Returns the specified annotation on this field.Returns metadata about the declaring class.Returns the full name of this field.getName()Returns the name of this field.<T> Optional<T>Same asget(Object)but wraps the results in anOptional.getType()Returns the type of this field.<A extends Annotation>
 booleanhasAnnotation(Class<A> type) Returnstrue if the specified annotation is present.<A extends Annotation>
 booleanhasAnnotation(AnnotationProvider annotationProvider, Class<A> type) Returnstrue if the specified annotation is present.booleanReturnstrue if the field has the specified name.<A extends Annotation>
 booleanhasNoAnnotation(Class<A> type) Returnstrue if the specified annotation is not present on this field.<A extends Annotation>
 booleanhasNoAnnotation(AnnotationProvider annotationProvider, Class<A> type) Returnstrue if the specified annotation is not present.inner()Returns the wrapped field.booleanis(ReflectFlags... flags) Returnstrue if all specified flags are applicable to this field.booleanisAll(ReflectFlags... flags) Returnstrue if all specified flags are applicable to this field.booleanisAny(ReflectFlags... flags) Returnstrue if all specified flags are applicable to this field.booleanReturnstrue if this field has the@Deprecatedannotation on it.booleanReturnstrue if this field doesn't have the@Deprecatedannotation on it.booleanReturnstrue if this field is not public.booleanReturnstrue if this field is not static.booleanReturnstrue if this field is not transient.booleanisPublic()Returnstrue if this field is public.booleanisStatic()Returnstrue if this field is static.booleanReturnstrue if this field is transient.booleanIdentifies if the specified visibility matches this field.booleanReturnstrue if this object passes the specified predicate test.static FieldInfoConvenience method for instantiating aFieldInfo;static FieldInfoConvenience method for instantiating aFieldInfo;voidSets the field value on the specified object.booleanAttempts to callx.setAccessible(and quietly ignores security exceptions.true )voidSets the field value on the specified object if the value isnull .toString()
- 
Constructor Details- 
FieldInfoConstructor.- Parameters:
- declaringClass- The class that declares this method.
- f- The field being wrapped.
 
 
- 
- 
Method Details- 
ofConvenience method for instantiating aFieldInfo;- Parameters:
- declaringClass- The class that declares this method.
- f- The field being wrapped.
- Returns:
- A new FieldInfoobject, ornull if the field was null.
 
- 
ofConvenience method for instantiating aFieldInfo;- Parameters:
- f- The field being wrapped.
- Returns:
- A new FieldInfoobject, ornull if the field was null.
 
- 
innerReturns the wrapped field.- Returns:
- The wrapped field.
 
- 
getDeclaringClassReturns metadata about the declaring class.- Returns:
- Metadata about the declaring class.
 
- 
getAnnotationReturns the specified annotation on this field.- Type Parameters:
- A- The annotation type to look for.
- Parameters:
- type- The annotation to look for.
- Returns:
- The annotation, or null if not found.
 
- 
getAnnotationReturns the specified annotation on this field.- Type Parameters:
- A- The annotation type to look for.
- Parameters:
- annotationProvider- The annotation provider.
- type- The annotation to look for.
- Returns:
- The annotation, or null if not found.
 
- 
hasAnnotationReturnstrue if the specified annotation is present.- Type Parameters:
- A- The annotation type to look for.
- Parameters:
- type- The annotation to look for.
- Returns:
- true if the specified annotation is present.
 
- 
hasNoAnnotationReturnstrue if the specified annotation is not present on this field.- Type Parameters:
- A- The annotation type to look for.
- Parameters:
- type- The annotation to look for.
- Returns:
- true if the specified annotation is not present on this field.
 
- 
hasAnnotationpublic <A extends Annotation> boolean hasAnnotation(AnnotationProvider annotationProvider, Class<A> type) Returnstrue if the specified annotation is present.- Type Parameters:
- A- The annotation type to look for.
- Parameters:
- annotationProvider- The annotation provider.
- type- The annotation to look for.
- Returns:
- true if the specified annotation is present.
 
- 
hasNoAnnotationpublic <A extends Annotation> boolean hasNoAnnotation(AnnotationProvider annotationProvider, Class<A> type) Returnstrue if the specified annotation is not present.- Type Parameters:
- A- The annotation type to look for.
- Parameters:
- annotationProvider- The annotation provider.
- type- The annotation to look for.
- Returns:
- true if the specified annotation is not present.
 
- 
isAllReturnstrue if all specified flags are applicable to this field.- Parameters:
- flags- The flags to test for.
- Returns:
- true if all specified flags are applicable to this field.
 
- 
isAnyReturnstrue if all specified flags are applicable to this field.- Parameters:
- flags- The flags to test for.
- Returns:
- true if all specified flags are applicable to this field.
 
- 
isReturnstrue if all specified flags are applicable to this field.- Parameters:
- flags- The flags to test for.
- Returns:
- true if all specified flags are applicable to this field.
 
- 
isDeprecatedReturnstrue if this field has the@Deprecatedannotation on it.- Returns:
- true if this field has the- @Deprecatedannotation on it.
 
- 
isNotDeprecatedReturnstrue if this field doesn't have the@Deprecatedannotation on it.- Returns:
- true if this field doesn't have the- @Deprecatedannotation on it.
 
- 
isPublicReturnstrue if this field is public.- Returns:
- true if this field is public.
 
- 
isNotPublicReturnstrue if this field is not public.- Returns:
- true if this field is not public.
 
- 
isStaticReturnstrue if this field is static.- Returns:
- true if this field is static.
 
- 
isNotStaticReturnstrue if this field is not static.- Returns:
- true if this field is not static.
 
- 
isTransientReturnstrue if this field is transient.- Returns:
- true if this field is transient.
 
- 
isNotTransientReturnstrue if this field is not transient.- Returns:
- true if this field is not transient.
 
- 
hasNameReturnstrue if the field has the specified name.- Parameters:
- name- The name to compare against.
- Returns:
- true if the field has the specified name.
 
- 
accessibleAttempts to callx.setAccessible(and quietly ignores security exceptions.true )- Returns:
- This object.
 
- 
setAccessibleAttempts to callx.setAccessible(and quietly ignores security exceptions.true )- Returns:
- true if call was successful.
 
- 
isVisibleIdentifies if the specified visibility matches this field.- Parameters:
- v- The visibility to validate against.
- Returns:
- true if this visibility matches the modifier attribute of this field.
 
- 
matchesReturnstrue if this object passes the specified predicate test.- Parameters:
- test- The test to perform.
- Returns:
- true if this object passes the specified predicate test.
 
- 
acceptPerforms an action on this object if the specified predicate test passes.- Parameters:
- test- A test to apply to determine if action should be executed. Can be- null .
- action- An action to perform on this object.
- Returns:
- This object.
 
- 
getTypeReturns the type of this field.- Returns:
- The type of this field.
 
- 
toString
- 
compareTo- Specified by:
- compareToin interface- Comparable<FieldInfo>
 
- 
getNameReturns the name of this field.- Returns:
- The name of this field.
 
- 
getFullNameReturns the full name of this field.Examples:- "com.foo.MyClass.myField" - Method.
 - Returns:
- The underlying executable name.
 
- 
getReturns the field value on the specified object.- Type Parameters:
- T- The object type to retrieve.
- Parameters:
- o- The object containing the field.
- Returns:
- The field value.
- Throws:
- BeanRuntimeException- Field was not accessible or field does not belong to object.
 
- 
getOptionalSame asget(Object)but wraps the results in anOptional.- Type Parameters:
- T- The object type to retrieve.
- Parameters:
- o- The object containing the field.
- Returns:
- The field value.
- Throws:
- BeanRuntimeException- Field was not accessible or field does not belong to object.
 
- 
setSets the field value on the specified object.- Parameters:
- o- The object containing the field.
- value- The new field value.
- Throws:
- BeanRuntimeException- Field was not accessible or field does not belong to object.
 
- 
setIfNullSets the field value on the specified object if the value isnull .- Parameters:
- o- The object containing the field.
- value- The new field value.
- Throws:
- BeanRuntimeException- Field was not accessible or field does not belong to object.
 
 
-