com.bazaarvoice.jolt.shiftr.spec.ShiftrLeafSpec Maven / Gradle / Ivy
/*
* Copyright 2013 Bazaarvoice, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bazaarvoice.jolt.shiftr.spec;
import com.bazaarvoice.jolt.Shiftr;
import com.bazaarvoice.jolt.common.pathelement.HashPathElement;
import com.bazaarvoice.jolt.common.pathelement.TransposePathElement;
import com.bazaarvoice.jolt.shiftr.ShiftrWriter;
import com.bazaarvoice.jolt.utils.StringTools;
import com.bazaarvoice.jolt.exception.SpecException;
import com.bazaarvoice.jolt.common.WalkedPath;
import com.bazaarvoice.jolt.common.pathelement.AtPathElement;
import com.bazaarvoice.jolt.common.pathelement.DollarPathElement;
import com.bazaarvoice.jolt.common.pathelement.LiteralPathElement;
import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Leaf level Spec object.
*
* If this Spec's PathElement matches the input (successful parallel tree walk)
* this Spec has the information needed to write the given data to the output object.
*/
public class ShiftrLeafSpec extends ShiftrSpec {
// List of the processed version of the "write specifications"
private final List shiftrWriters;
public ShiftrLeafSpec( String rawKey, Object rhs ) {
super( rawKey );
List writers;
if ( rhs instanceof String ) {
// leaf level so spec is an dot notation write path
writers = Arrays.asList( parseOutputDotNotation( rhs ) );
}
else if ( rhs instanceof List ) {
// leaf level list
// Spec : "foo": ["a", "b"] : Shift the value of "foo" to both "a" and "b"
@SuppressWarnings( "unchecked" )
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy