Package com.bazaarvoice.jolt
Class Modifier
- java.lang.Object
-
- com.bazaarvoice.jolt.Modifier
-
- All Implemented Interfaces:
ContextualTransform
,JoltTransform
,SpecDriven
- Direct Known Subclasses:
Modifier.Defaultr
,Modifier.Definr
,Modifier.Overwritr
public abstract class Modifier extends java.lang.Object implements SpecDriven, ContextualTransform
Base Templatr transform that to behave differently based on provided opMode
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Modifier.Defaultr
This variant of modifier only writes when the key/index is missing or the value is nullstatic class
Modifier.Definr
This variant of modifier only writes when the key/index is missingstatic class
Modifier.Overwritr
This variant of modifier creates the key/index is missing, and overwrites the value if present
-
Field Summary
Fields Modifier and Type Field Description private ModifierCompositeSpec
rootSpec
private static java.util.Map<java.lang.String,Function>
STOCK_FUNCTIONS
-
Fields inherited from interface com.bazaarvoice.jolt.SpecDriven
ROOT_KEY
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
transform(java.lang.Object input, java.util.Map<java.lang.String,java.lang.Object> context)
Execute a transform on some input JSON with optionally provided "context" and return the result.
-
-
-
Field Detail
-
STOCK_FUNCTIONS
private static final java.util.Map<java.lang.String,Function> STOCK_FUNCTIONS
-
rootSpec
private final ModifierCompositeSpec rootSpec
-
-
Method Detail
-
transform
public java.lang.Object transform(java.lang.Object input, java.util.Map<java.lang.String,java.lang.Object> context)
Description copied from interface:ContextualTransform
Execute a transform on some input JSON with optionally provided "context" and return the result. The "context" allows transforms to tweak their behavior based upon criteria outside of the input JSON object. The canonical example for the need to have Transforms consider "context" is a Transform that creates urls based upon input data. Should it generate "http" or "https" urls? Most likely the input JSON data does not provide any guidance. This is what the "context" is for. It allows the consumer of the Transform to specialize itself based on data outside the scope of the input JSON. Without the "context" notion you would instead create a HttpUrlTransform and a HttpsUrlTransform. This creates problems when you want to used them as part of a larger Chainr Transform, as you would need to create two Chainrs that are almost the same. The number of Chainrs needed grows exponentially as you add other context sensitive transforms.- Specified by:
transform
in interfaceContextualTransform
- Parameters:
input
- the JSON object to transform in plain vanilla Jackson Mapstyle context
- information outside of the input JSON that needs to be taken into account when doing the transform- Returns:
- the results of the transformation
-
-