Class ObjectGraphScanner

java.lang.Object
de.xima.fc.helper.ObjectGraphScanner

public final class ObjectGraphScanner extends Object
A scanner for visiting each instance field of an object via reflection. The traversal is recursive.
Since:
7.0.0
Author:
XIMA MEDIA GmbH
  • Constructor Details

    • ObjectGraphScanner

      public ObjectGraphScanner()
  • Method Details

    • 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 to Modifier.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 if EObjectGraphVisitResult.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 and UuidEntityRef 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 and UuidEntityRef 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 is null. When this is set, the visitor is called even for null 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 for null values.