Class CardinalitySpec

java.lang.Object
com.bazaarvoice.jolt.cardinality.CardinalitySpec
All Implemented Interfaces:
BaseSpec
Direct Known Subclasses:
CardinalityCompositeSpec, CardinalityLeafSpec

public abstract class CardinalitySpec extends Object implements BaseSpec
A Spec Object represents a single line from the JSON Cardinality Spec. At a minimum a single Spec has : Raw LHS spec value Some kind of PathElement (based off that raw LHS value) Additionally there are 2 distinct subclasses of the base Spec CardinalityLeafSpec : where the RHS is either "ONE" or "MANY" CardinalityCompositeSpec : where the RHS is a map of children Specs The tree structure of formed by the CompositeSpecs is what is used during the transform to do the parallel tree walk with the input data tree. During the parallel tree walk, a Path is maintained, and used when a tree walk encounters a leaf spec.
  • Field Details

  • Constructor Details

    • CardinalitySpec

      public CardinalitySpec(String rawJsonKey)
  • Method Details

    • parse

      public static List<PathElement> parse(String key)
    • applyCardinality

      public abstract boolean applyCardinality(String inputKey, Object input, WalkedPath walkedPath, Object parentContainer)
      This is the main recursive method of the CardinalityTransform 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 CardinalityTransform parallel treewalk, if this method returns a non-null Object, the assumption is that no other sibling Cardinality specs need to look at this particular input key.
      Returns:
      true if this this spec "handles" the inputkey such that no sibling specs need to see it
    • 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
    • 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