001/* 002 * Copyright (c) 2007-2022 The Cascading Authors. All Rights Reserved. 003 * 004 * Project and contact information: https://cascading.wensel.net/ 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.json; 022 023import java.beans.ConstructorProperties; 024import java.util.Map; 025import java.util.stream.Stream; 026 027import cascading.nested.core.NestedAggregate; 028import cascading.nested.core.NestedGetAllAggregateFunction; 029import cascading.operation.SerFunction; 030import cascading.tuple.Fields; 031import com.fasterxml.jackson.databind.JsonNode; 032import com.fasterxml.jackson.databind.node.ArrayNode; 033 034/** 035 * Class JSONGetAllAggregateFunction provides the ability to retrieve a list of child nodes and 036 * convert the specified properties of each JSON object into a new aggregate value rendered by the given implementation 037 * of {@link NestedAggregate}. 038 * <p> 039 * Note the {@code stringRootPointer} may reference a JSON Array, {@code /person/*}, or it may be a pointer-path 040 * descent reference, {@code /person/**}{@code /name}. In the later case, use an empty pointer, {@code ""}, to reference 041 * the value of the array. 042 * <p> 043 * See {@link cascading.nested.core.aggregate.SimpleNestedAggregate} for a convenient base implementation. 044 * 045 * @see <a href=https://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-03">draft-ietf-appsawg-json-pointer-03</a> 046 * @see NestedGetAllAggregateFunction for more details. 047 */ 048public class JSONGetAllAggregateFunction extends NestedGetAllAggregateFunction<JsonNode, ArrayNode> 049 { 050 /** 051 * Constructor JSONGetAllAggregateFunction creates a new instance. 052 * 053 * @param stringRootPointer of type String 054 * @param pointerMap of type Map 055 */ 056 @ConstructorProperties({"stringRootPointer", "pointerMap"}) 057 public JSONGetAllAggregateFunction( String stringRootPointer, Map<String, NestedAggregate<JsonNode, ?>> pointerMap ) 058 { 059 this( stringRootPointer, false, pointerMap ); 060 } 061 062 /** 063 * Constructor JSONGetAllAggregateFunction creates a new instance. 064 * 065 * @param stringRootPointer of type String 066 * @param failOnMissingNode of type boolean 067 * @param pointerMap of type Map 068 */ 069 @ConstructorProperties({"stringRootPointer", "failOnMissingNode", "pointerMap"}) 070 public JSONGetAllAggregateFunction( String stringRootPointer, boolean failOnMissingNode, Map<String, NestedAggregate<JsonNode, ?>> pointerMap ) 071 { 072 super( JSONCoercibleType.TYPE, stringRootPointer, failOnMissingNode, pointerMap ); 073 } 074 075 /** 076 * Constructor JSONGetAllAggregateFunction creates a new instance. 077 * 078 * @param coercibleType of type JSONCoercibleType 079 * @param stringRootPointer of type String 080 * @param pointerMap of type Map 081 */ 082 @ConstructorProperties({"coercibleType", "stringRootPointer", "pointerMap"}) 083 public JSONGetAllAggregateFunction( JSONCoercibleType coercibleType, String stringRootPointer, Map<String, NestedAggregate<JsonNode, ?>> pointerMap ) 084 { 085 this( coercibleType, stringRootPointer, false, pointerMap ); 086 } 087 088 /** 089 * Constructor JSONGetAllAggregateFunction creates a new instance. 090 * 091 * @param coercibleType of type JSONCoercibleType 092 * @param stringRootPointer of type String 093 * @param failOnMissingNode of type boolean 094 * @param pointerMap of type Map 095 */ 096 @ConstructorProperties({"coercibleType", "stringRootPointer", "failOnMissingNode", "pointerMap"}) 097 public JSONGetAllAggregateFunction( JSONCoercibleType coercibleType, String stringRootPointer, boolean failOnMissingNode, Map<String, NestedAggregate<JsonNode, ?>> pointerMap ) 098 { 099 super( coercibleType, stringRootPointer, failOnMissingNode, pointerMap ); 100 } 101 102 /** 103 * Constructor JSONGetAllAggregateFunction creates a new instance. 104 * 105 * @param stringRootPointer of type String 106 * @param streamWrapper of type SerFunction 107 * @param pointerMap of type Map 108 */ 109 @ConstructorProperties({"stringRootPointer", "streamWrapper", "pointerMap"}) 110 public JSONGetAllAggregateFunction( String stringRootPointer, SerFunction<Stream<JsonNode>, Stream<JsonNode>> streamWrapper, Map<String, NestedAggregate<JsonNode, ?>> pointerMap ) 111 { 112 this( stringRootPointer, streamWrapper, false, pointerMap ); 113 } 114 115 /** 116 * Constructor JSONGetAllAggregateFunction creates a new instance. 117 * 118 * @param stringRootPointer of type String 119 * @param streamWrapper of type SerFunction 120 * @param failOnMissingNode of type boolean 121 * @param pointerMap of type Map 122 */ 123 @ConstructorProperties({"stringRootPointer", "streamWrapper", "failOnMissingNode", "pointerMap"}) 124 public JSONGetAllAggregateFunction( String stringRootPointer, SerFunction<Stream<JsonNode>, Stream<JsonNode>> streamWrapper, boolean failOnMissingNode, Map<String, NestedAggregate<JsonNode, ?>> pointerMap ) 125 { 126 super( JSONCoercibleType.TYPE, stringRootPointer, streamWrapper, failOnMissingNode, pointerMap ); 127 } 128 129 /** 130 * Constructor JSONGetAllAggregateFunction creates a new instance. 131 * 132 * @param coercibleType of type JSONCoercibleType 133 * @param stringRootPointer of type String 134 * @param streamWrapper of type SerFunction 135 * @param pointerMap of type Map 136 */ 137 @ConstructorProperties({"coercibleType", "stringRootPointer", "streamWrapper", "pointerMap"}) 138 public JSONGetAllAggregateFunction( JSONCoercibleType coercibleType, String stringRootPointer, SerFunction<Stream<JsonNode>, Stream<JsonNode>> streamWrapper, Map<String, NestedAggregate<JsonNode, ?>> pointerMap ) 139 { 140 this( coercibleType, stringRootPointer, streamWrapper, false, pointerMap ); 141 } 142 143 /** 144 * Constructor JSONGetAllAggregateFunction creates a new instance. 145 * 146 * @param coercibleType of type JSONCoercibleType 147 * @param stringRootPointer of type String 148 * @param streamWrapper of type SerFunction 149 * @param failOnMissingNode of type boolean 150 * @param pointerMap of type Map 151 */ 152 @ConstructorProperties({"coercibleType", "stringRootPointer", "streamWrapper", "failOnMissingNode", "pointerMap"}) 153 public JSONGetAllAggregateFunction( JSONCoercibleType coercibleType, String stringRootPointer, SerFunction<Stream<JsonNode>, Stream<JsonNode>> streamWrapper, boolean failOnMissingNode, Map<String, NestedAggregate<JsonNode, ?>> pointerMap ) 154 { 155 super( coercibleType, stringRootPointer, streamWrapper, failOnMissingNode, pointerMap ); 156 } 157 158 /** 159 * Constructor JSONGetAllAggregateFunction creates a new instance. 160 * 161 * @param stringRootPointer of type String 162 * @param fieldDeclaration of the Fields 163 * @param stringPointers of type String[] 164 * @param nestedAggregates of type NestedAggregate[] 165 */ 166 @ConstructorProperties({"stringRootPointer", "streamWrapper", "fieldDeclaration", 167 "stringPointers", "nestedAggregates"}) 168 public JSONGetAllAggregateFunction( String stringRootPointer, Fields fieldDeclaration, String[] stringPointers, NestedAggregate<JsonNode, ?>[] nestedAggregates ) 169 { 170 this( stringRootPointer, fieldDeclaration, false, stringPointers, nestedAggregates ); 171 } 172 173 /** 174 * Constructor JSONGetAllAggregateFunction creates a new instance. 175 * 176 * @param stringRootPointer of type String 177 * @param failOnMissingNode of type boolean 178 * @param fieldDeclaration of the Fields 179 * @param failOnMissingNode of type boolean 180 * @param stringPointers of type String[] 181 * @param nestedAggregates of type NestedAggregate[] 182 */ 183 @ConstructorProperties({"stringRootPointer", "fieldDeclaration", 184 "failOnMissingNode", "stringPointers", "nestedAggregates"}) 185 public JSONGetAllAggregateFunction( String stringRootPointer, Fields fieldDeclaration, boolean failOnMissingNode, String[] stringPointers, NestedAggregate<JsonNode, ?>[] nestedAggregates ) 186 { 187 super( JSONCoercibleType.TYPE, stringRootPointer, fieldDeclaration, failOnMissingNode, stringPointers, nestedAggregates ); 188 } 189 190 /** 191 * Constructor JSONGetAllAggregateFunction creates a new instance. 192 * 193 * @param coercibleType of type JSONCoercibleType 194 * @param stringRootPointer of type String 195 * @param fieldDeclaration of the Fields 196 * @param stringPointers of type String[] 197 * @param nestedAggregates of type NestedAggregate[] 198 */ 199 @ConstructorProperties({"coercibleType", "stringRootPointer", "fieldDeclaration", 200 "stringPointers", "nestedAggregates"}) 201 public JSONGetAllAggregateFunction( JSONCoercibleType coercibleType, String stringRootPointer, Fields fieldDeclaration, String[] stringPointers, NestedAggregate<JsonNode, ?>[] nestedAggregates ) 202 { 203 this( coercibleType, stringRootPointer, fieldDeclaration, false, stringPointers, nestedAggregates ); 204 } 205 206 /** 207 * Constructor JSONGetAllAggregateFunction creates a new instance. 208 * 209 * @param coercibleType of type JSONCoercibleType 210 * @param stringRootPointer of type String 211 * @param failOnMissingNode of type boolean 212 * @param fieldDeclaration of the Fields 213 * @param failOnMissingNode of type boolean 214 * @param stringPointers of type String[] 215 * @param nestedAggregates of type NestedAggregate[] 216 */ 217 @ConstructorProperties({"coercibleType", "stringRootPointer", "fieldDeclaration", 218 "failOnMissingNode", "stringPointers", "nestedAggregates"}) 219 public JSONGetAllAggregateFunction( JSONCoercibleType coercibleType, String stringRootPointer, Fields fieldDeclaration, boolean failOnMissingNode, String[] stringPointers, NestedAggregate<JsonNode, ?>[] nestedAggregates ) 220 { 221 super( coercibleType, stringRootPointer, fieldDeclaration, failOnMissingNode, stringPointers, nestedAggregates ); 222 } 223 224 /** 225 * Constructor JSONGetAllAggregateFunction creates a new instance. 226 * 227 * @param stringRootPointer of type String 228 * @param streamWrapper of type SerFunction 229 * @param fieldDeclaration of the Fields 230 * @param stringPointers of type String[] 231 * @param nestedAggregates of type NestedAggregate[] 232 */ 233 @ConstructorProperties({"stringRootPointer", "streamWrapper", "fieldDeclaration", 234 "stringPointers", "nestedAggregates"}) 235 public JSONGetAllAggregateFunction( String stringRootPointer, SerFunction<Stream<JsonNode>, Stream<JsonNode>> streamWrapper, Fields fieldDeclaration, String[] stringPointers, NestedAggregate<JsonNode, ?>[] nestedAggregates ) 236 { 237 this( stringRootPointer, streamWrapper, fieldDeclaration, false, stringPointers, nestedAggregates ); 238 } 239 240 /** 241 * Constructor JSONGetAllAggregateFunction creates a new instance. 242 * 243 * @param stringRootPointer of type String 244 * @param streamWrapper of type SerFunction 245 * @param failOnMissingNode of type boolean 246 * @param fieldDeclaration of the Fields 247 * @param failOnMissingNode of type boolean 248 * @param stringPointers of type String[] 249 * @param nestedAggregates of type NestedAggregate[] 250 */ 251 @ConstructorProperties({"stringRootPointer", "streamWrapper", "fieldDeclaration", 252 "failOnMissingNode", "stringPointers", "nestedAggregates"}) 253 public JSONGetAllAggregateFunction( String stringRootPointer, SerFunction<Stream<JsonNode>, Stream<JsonNode>> streamWrapper, Fields fieldDeclaration, boolean failOnMissingNode, String[] stringPointers, NestedAggregate<JsonNode, ?>[] nestedAggregates ) 254 { 255 this( JSONCoercibleType.TYPE, stringRootPointer, streamWrapper, fieldDeclaration, failOnMissingNode, stringPointers, nestedAggregates ); 256 } 257 258 /** 259 * Constructor JSONGetAllAggregateFunction creates a new instance. 260 * 261 * @param coercibleType of type JSONCoercibleType 262 * @param stringRootPointer of type String 263 * @param streamWrapper of type SerFunction 264 * @param fieldDeclaration of the Fields 265 * @param stringPointers of type String[] 266 * @param nestedAggregates of type NestedAggregate[] 267 */ 268 @ConstructorProperties({"coercibleType", "stringRootPointer", "streamWrapper", "fieldDeclaration", 269 "stringPointers", "nestedAggregates"}) 270 public JSONGetAllAggregateFunction( JSONCoercibleType coercibleType, String stringRootPointer, SerFunction<Stream<JsonNode>, Stream<JsonNode>> streamWrapper, Fields fieldDeclaration, String[] stringPointers, NestedAggregate<JsonNode, ?>[] nestedAggregates ) 271 { 272 this( coercibleType, stringRootPointer, streamWrapper, fieldDeclaration, false, stringPointers, nestedAggregates ); 273 } 274 275 /** 276 * Constructor JSONGetAllAggregateFunction creates a new instance. 277 * 278 * @param coercibleType of type JSONCoercibleType 279 * @param stringRootPointer of type String 280 * @param streamWrapper of type SerFunction 281 * @param failOnMissingNode of type boolean 282 * @param stringPointers of type String[] 283 * @param nestedAggregates of type NestedAggregate[] 284 */ 285 @ConstructorProperties({"coercibleType", "stringRootPointer", "streamWrapper", 286 "failOnMissingNode", "stringPointers", "nestedAggregates"}) 287 public JSONGetAllAggregateFunction( JSONCoercibleType coercibleType, String stringRootPointer, SerFunction<Stream<JsonNode>, Stream<JsonNode>> streamWrapper, boolean failOnMissingNode, String[] stringPointers, NestedAggregate<JsonNode, ?>[] nestedAggregates ) 288 { 289 super( coercibleType, stringRootPointer, streamWrapper, failOnMissingNode, stringPointers, nestedAggregates ); 290 } 291 292 /** 293 * Constructor JSONGetAllAggregateFunction creates a new instance. 294 * 295 * @param coercibleType of type JSONCoercibleType 296 * @param stringRootPointer of type String 297 * @param streamWrapper of type SerFunction 298 * @param fieldDeclaration of the Fields 299 * @param failOnMissingNode of type boolean 300 * @param stringPointers of type String[] 301 * @param nestedAggregates of type NestedAggregate[] 302 */ 303 @ConstructorProperties({"coercibleType", "stringRootPointer", "streamWrapper", "fieldDeclaration", 304 "failOnMissingNode", "stringPointers", "nestedAggregates"}) 305 public JSONGetAllAggregateFunction( JSONCoercibleType coercibleType, String stringRootPointer, SerFunction<Stream<JsonNode>, Stream<JsonNode>> streamWrapper, Fields fieldDeclaration, boolean failOnMissingNode, String[] stringPointers, NestedAggregate<JsonNode, ?>[] nestedAggregates ) 306 { 307 super( coercibleType, stringRootPointer, streamWrapper, fieldDeclaration, failOnMissingNode, stringPointers, nestedAggregates ); 308 } 309 }