Package com.bazaarvoice.jolt.cardinality
Class CardinalitySpec
- java.lang.Object
-
- com.bazaarvoice.jolt.cardinality.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 Pathis maintained, and used when a tree walk encounters a leaf spec.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
AT
protected MatchablePathElement
pathElement
private static java.lang.String
STAR
-
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 elementstatic java.util.List<PathElement>
parse(java.lang.String key)
-
-
-
Field Detail
-
STAR
private static final java.lang.String STAR
- See Also:
- Constant Field Values
-
AT
private static final java.lang.String AT
- See Also:
- Constant Field Values
-
pathElement
protected final MatchablePathElement pathElement
-
-
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.
-
getPathElement
public MatchablePathElement getPathElement()
Description copied from interface:BaseSpec
Gimme the LHS path element- Specified by:
getPathElement
in interfaceBaseSpec
- Returns:
- LHS path element for comparison
-
-