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. Also traverses into containers (List, Set, Map) and their items.
Since:
7.0.0
Author:
XIMA MEDIA GmbH
  • Constructor Details

    • ObjectGraphScanner

      public ObjectGraphScanner()
  • Method Details

    • alsoExcludeClasses

      @CanIgnoreReturnValue 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 IObjectReference are excluded.
      Returns:
      This scanner for chaining configuration calls.
    • disallowedModifiers

      @CanIgnoreReturnValue 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.
    • evaluationContext

      @CanIgnoreReturnValue public ObjectGraphScanner evaluationContext(Object context)
      Sets the context object that is made available via the context variable when evaluating expressions such as ApplicableIf.
      Parameters:
      context - The context object. If null, an empty object is used.
      Returns:
      This scanner for chaining configuration calls.
    • evaluator

      @CanIgnoreReturnValue public ObjectGraphScanner evaluator(IElEvaluator evaluator)
      Sets the ElEvaluators to use for evaluating conditions such as ApplicableIf. If not set, a default evaluator is used.
      Parameters:
      evaluator - The evaluator to use.
      Returns:
      This scanner for chaining configuration calls.
    • excludedClasses

      @CanIgnoreReturnValue 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 IObjectReference are excluded.
      Returns:
      This scanner for chaining configuration calls.
    • ignoreCircularReferences

      @CanIgnoreReturnValue 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.
    • ignoreConditions

      @CanIgnoreReturnValue public ObjectGraphScanner ignoreConditions()
      By default, conditions such as ApplicableIf are evaluated. When this is set to true, such conditions are skipped.
      Returns:
      This scanner for chaining configuration calls.
    • ignoreConditions

      @CanIgnoreReturnValue public ObjectGraphScanner ignoreConditions(boolean ignoreConditions)
      By default, conditions such as ApplicableIf are evaluated. When this is set to true, such conditions are skipped.
      Parameters:
      ignoreConditions - If true, conditions are ignored and not evaluated.
      Returns:
      This scanner for chaining configuration calls.
    • skipClassFields

      @CanIgnoreReturnValue public ObjectGraphScanner skipClassFields()
      By default, IObjectGraphVisitor.visitClassField(Object, Field, ObjectGraphValues) is called whenever a class field is encountered. When this is set, class fields are skipped.
      Returns:
      This scanner for chaining configuration calls.
    • skipListItems

      @CanIgnoreReturnValue public ObjectGraphScanner skipListItems()
      By default, IObjectGraphVisitor.visitListItem(Object, int, List) is called whenever a list item is encountered. When this is set, list items are skipped.
      Returns:
      This scanner for chaining configuration calls.
    • skipMapItems

      @CanIgnoreReturnValue public ObjectGraphScanner skipMapItems()
      By default, IObjectGraphVisitor.visitMapItem(Object, Object, Map) is called whenever a map item is encountered. When this is set, map items are skipped.
      Returns:
      This scanner for chaining configuration calls.
    • skipSetItems

      @CanIgnoreReturnValue public ObjectGraphScanner skipSetItems()
      By default, IObjectGraphVisitor.visitSetItem(Object, Set) is called whenever a set item is encountered. When this is set, set items are skipped.
      Returns:
      This scanner for chaining configuration calls.
    • 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

      @CanIgnoreReturnValue public ObjectGraphScanner visitNullKeys()
      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.
      Returns:
      This scanner for chaining configuration calls.
    • visitNullValues

      @CanIgnoreReturnValue public ObjectGraphScanner visitNullValues()
      By default, visitor methods are not called when the value is null. When this is set, the visitor is called even for null values.
      Returns:
      This scanner for chaining configuration calls.