Class CardinalitySpec

  • All Implemented Interfaces:
    BaseSpec
    Direct Known Subclasses:
    CardinalityCompositeSpec, CardinalityLeafSpec

    public abstract class CardinalitySpec
    extends java.lang.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.
    • Constructor Summary

      Constructors 
      Constructor Description
      CardinalitySpec​(java.lang.String rawJsonKey)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean apply​(java.lang.String inputKey, Optional<java.lang.Object> inputOptional, WalkedPath walkedPath, java.util.Map<java.lang.String,​java.lang.Object> output, java.util.Map<java.lang.String,​java.lang.Object> context)
      This is the main recursive method of the Shiftr/Templatr/Cardinality parallel "spec" and "input" tree walk.
      abstract boolean applyCardinality​(java.lang.String inputKey, java.lang.Object input, WalkedPath walkedPath, java.lang.Object parentContainer)
      This is the main recursive method of the CardinalityTransform parallel "spec" and "input" tree walk.
      MatchablePathElement getPathElement()
      Gimme the LHS path element
      static java.util.List<PathElement> parse​(java.lang.String key)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CardinalitySpec

        public CardinalitySpec​(java.lang.String rawJsonKey)
    • Method Detail

      • parse

        public static java.util.List<PathElement> parse​(java.lang.String key)
      • applyCardinality

        public abstract boolean applyCardinality​(java.lang.String inputKey,
                                                 java.lang.Object input,
                                                 WalkedPath walkedPath,
                                                 java.lang.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​(java.lang.String inputKey,
                             Optional<java.lang.Object> inputOptional,
                             WalkedPath walkedPath,
                             java.util.Map<java.lang.String,​java.lang.Object> output,
                             java.util.Map<java.lang.String,​java.lang.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