Class ModifierSpec

java.lang.Object
com.bazaarvoice.jolt.modifier.spec.ModifierSpec
All Implemented Interfaces:
BaseSpec
Direct Known Subclasses:
ModifierCompositeSpec, ModifierLeafSpec

public abstract class ModifierSpec extends Object implements BaseSpec
Base Templatr spec
  • Field Details

    • TRAVERSAL_BUILDER

      protected static final TraversalBuilder TRAVERSAL_BUILDER
    • opMode

      protected final OpMode opMode
    • pathElement

      protected final MatchablePathElement pathElement
    • checkValue

      protected final boolean checkValue
  • Constructor Details

    • ModifierSpec

      protected ModifierSpec(String rawJsonKey, OpMode opMode)
      Builds LHS pathElement and validates to specification
  • Method Details

    • getPathElement

      public MatchablePathElement getPathElement()
      Description copied from interface: BaseSpec
      Gimme the LHS path element
      Specified by:
      getPathElement in interface BaseSpec
      Returns:
      LHS path element for comparison
    • apply

      public boolean apply(String inputKey, Optional<Object> inputOptional, WalkedPath walkedPath, Map<String,Object> output, Map<String,Object> context)
      Description copied from interface: BaseSpec
      This is the main recursive method of the Shiftr/Templatr/Cardinality parallel "spec" and "input" tree walk. It should return true if this Spec object was able to successfully apply itself given the inputKey and input object. In the context of the Shiftr parallel treewalk, if this method returns true, the assumption is that no other sibling Shiftr specs need to look at this particular input key.
      Specified by:
      apply in interface BaseSpec
      Returns:
      true if this this spec "handles" the inputkey such that no sibling specs need to see it
    • applyElement

      protected abstract void applyElement(String key, Optional<Object> inputOptional, MatchedElement thisLevel, WalkedPath walkedPath, Map<String,Object> context)
      Templatr specific override that is used in BaseSpec#apply(...) The name is changed for easy identification during debugging
    • setData

      protected static void setData(Object parent, MatchedElement matchedElement, Object value, OpMode opMode)
      Static utility method for facilitating writes on input object
      Parameters:
      parent - the source object
      matchedElement - the current spec (leaf) element that was matched with input
      value - to write
      opMode - to determine if write is applicable