001/* 002 * Copyright (c) 2016-2017 Chris K Wensel. All Rights Reserved. 003 * 004 * Project and contact information: http://www.cascading.org/ 005 * 006 * This file is part of the Cascading project. 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020 021package cascading.nested.core; 022 023import java.lang.reflect.Type; 024 025import heretical.pointer.operation.CopySpec; 026 027/** 028 * Class BuildSpec is used to declare how a key value maps into a new or existing nested object type. 029 * <p> 030 * To map child elements from one nested object to another, see {@link CopySpec} and related operations. 031 * <p> 032 * When using a BuildSpec, you are declaring that a field value is put into a specific location in a nested object 033 * type. 034 * <p> 035 * When a BuildSpec is created, the target root location of all the values must be declared, or all values will 036 * be placed immediately below the root object. 037 * <p> 038 * For example, you want to put a field named {@code firstName} it into a JSON tree at {@code /person/firstName} 039 * there are two ways to use a BuildSpec. 040 * <p> 041 * Either 042 * <p> 043 * {@code 044 * new BuildSpec().putInto( "firstName", "/person/firstName" ); 045 * } 046 * <p> 047 * Or 048 * <p> 049 * {@code 050 * new BuildSpec( "/person" ).putInto( "firstName", "/firstName" ); 051 * } 052 * <p> 053 * Note that a field being copied or put into the new object can also be a nested object. In the case of JSON 054 * if the object to be copied is a JSON String, the value can be converted to a JSON object on the copy. 055 * <p> 056 * {@code 057 * new BuildSpec().putInto( "person", JSONCoercibleType.TYPE, "/person" ); 058 * } 059 * <p> 060 * This example assumes the {@code person} field is a valid JSON String or already a JSON {@code JsonNode} instance. 061 * 062 * @see CopySpec 063 */ 064public class BuildSpec extends heretical.pointer.operation.BuildSpec<BuildSpec> 065 { 066 public BuildSpec() 067 { 068 } 069 070 public BuildSpec( Type defaultType ) 071 { 072 super( defaultType ); 073 } 074 075 public BuildSpec( String intoPointer ) 076 { 077 super( intoPointer ); 078 } 079 080 public BuildSpec( String intoPointer, Type defaultType ) 081 { 082 super( intoPointer, defaultType ); 083 } 084 }