Package de.xima.fc.helper
Class ObjectGraphScanner
- java.lang.Object
-
- de.xima.fc.helper.ObjectGraphScanner
-
public final class ObjectGraphScanner extends Object
A scanner for visiting each field of an object via reflection.- Since:
- 7.0.0
- Author:
- XIMA MEDIA GmbH
-
-
Constructor Summary
Constructors Constructor Description ObjectGraphScanner()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectGraphScanner
alsoExcludeClasses(Predicate<Class<?>> additionalPredicate)
ObjectGraphScanner
disallowedModifiers(int disallowedModifiers)
ObjectGraphScanner
excludedClasses(Predicate<Class<?>> excludedClasses)
ObjectGraphScanner
ignoreCircularReferences()
By default, an exception is thrown when circular references are encountered.ObjectGraphScanner
skipClassFields()
ObjectGraphScanner
skipListItems()
ObjectGraphScanner
skipMapItems()
ObjectGraphScanner
skipSetItems()
void
visit(Object value, IObjectGraphVisitor visitor)
Visits each field, list item, and map item of the given object (excluding the object itself), according to the current configuration.ObjectGraphScanner
visitNullKeys()
ObjectGraphScanner
visitNullValues()
-
-
-
Method Detail
-
disallowedModifiers
public ObjectGraphScanner disallowedModifiers(int disallowedModifiers)
- Parameters:
disallowedModifiers
- Modifiers that when present on a class field, the field is skipped and neither the field nor its children are visited. Defaults toModifier.FINAL | Modifier.STATIC | Modifier.TRANSIENT
.- Returns:
- This scanner for chaining configuration calls.
-
ignoreCircularReferences
public ObjectGraphScanner ignoreCircularReferences()
By default, an exception is thrown when circular references are encountered. Call this method to silently ignore circular references as ifEObjectGraphVisitResult.REJECT
had been returned.- Returns:
- This scanner for chaining configuration calls.
-
alsoExcludeClasses
public ObjectGraphScanner alsoExcludeClasses(Predicate<Class<?>> additionalPredicate)
- Parameters:
additionalPredicate
- Additional classes in additional to the current ones that should be considered primitives. Traversal will never recurse into these classes. By default,java.*
classes andUuidEntityRef
are excluded.- Returns:
- This scanner for chaining configuration calls.
-
excludedClasses
public ObjectGraphScanner excludedClasses(Predicate<Class<?>> excludedClasses)
- Parameters:
excludedClasses
- Classes that should be considered primitives. Traversal will never recurse into these classes. By default,java.*
classes andUuidEntityRef
are excluded.- Returns:
- This scanner for chaining configuration calls.
-
skipClassFields
public ObjectGraphScanner skipClassFields()
- Returns:
- By default,
IObjectGraphVisitor.visitClassField(Object, Field, Object)
is called whenever a class field is encountered. When this is set, class fields are skipped.
-
skipListItems
public ObjectGraphScanner skipListItems()
- Returns:
- By default,
IObjectGraphVisitor.visitListItem(Object, int, List)
is called whenever a list item is encountered. When this is set, list items are skipped.
-
skipMapItems
public ObjectGraphScanner skipMapItems()
- Returns:
- By default,
IObjectGraphVisitor.visitMapItem(Object, Object, Map)
is called whenever a map item is encountered. When this is set, map items are skipped.
-
skipSetItems
public ObjectGraphScanner skipSetItems()
- Returns:
- By default,
IObjectGraphVisitor.visitSetItem(Object, Set)
is called whenever a set item is encountered. When this is set, set items are skipped.
-
visit
public void visit(Object value, IObjectGraphVisitor visitor)
Visits each field, list item, and map item of the given object (excluding the object itself), according to the current configuration.- Parameters:
value
- Object to visit.visitor
- Visitor that handles the object's fields.
-
visitNullKeys
public ObjectGraphScanner visitNullKeys()
- Returns:
- By default,
IObjectGraphVisitor.visitMapItem(Object, Object, Map)
is not called when the map key isnull
. When this is set, the visitor is called even fornull
map keys.
-
visitNullValues
public ObjectGraphScanner visitNullValues()
- Returns:
- By default, visitor methods are not called when the value is
null
. When this is set, the visitor is called even fornull
values.
-
-