Class AbstractReflection
java.lang.Object
org.apache.commons.lang3.builder.AbstractReflection
- Direct Known Subclasses:
CompareToBuilder, EqualsBuilder, HashCodeBuilder, ReflectionDiffBuilder, ToStringBuilder
Abstracts reflection access for reflection-based classes in this package.
See AbstractReflection.AbstractBuilder.setForceAccessible(boolean) for details.
- Since:
- 3.21.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilds an instance of a subclass ofAbstractReflection. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanGets whether the system property"AbstractReflection.forceAccessible"is set to true.protected booleanTests whether fields should be made accessible withAccessibleObject.setAccessible(boolean).static booleansetAccessible(boolean forceAccessible, AccessibleObject accessibleObject) SetsaccessibleObjectto be accessible ifforceAccessibleis true and the object is not already accessible.
-
Method Details
-
getForceAccessible
Gets whether the system property"AbstractReflection.forceAccessible"is set to true.The parsing rules are defined by
Boolean.parseBoolean(String).If the property is not set, return true.
- Returns:
- whether the system property
"AbstractReflection.forceAccessible"is set to true with true as the default. - Since:
- 3.21.0
- See Also:
-
setAccessible
SetsaccessibleObjectto be accessible ifforceAccessibleis true and the object is not already accessible. CallsAccessibleObject#setAccessible(true).- Parameters:
forceAccessible- Whether to callAccessibleObject.setAccessible(boolean)if the object is not already accessible.accessibleObject- The accessible object to set; may benull.- Returns:
trueifaccessibleObjectis non-null and accessible after this call;falseotherwise (including whenaccessibleObjectisnull, or when it is inaccessible andforceAccessibleisfalse).- Throws:
SecurityException- Thrown ifforceAccessibleis true and the request is denied.- See Also:
-
isForceAccessible
Tests whether fields should be made accessible withAccessibleObject.setAccessible(boolean).- Returns:
- whether fields should be made accessible with
AccessibleObject.setAccessible(boolean).
-