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.Collections; 025import java.util.List; 026import java.util.regex.Pattern; 027 028import cascading.nested.core.NestedRegexFilter; 029 030/** 031 * Class JSONRegexFilter provides for the ability to to filter a tuple stream based on the values in a JSON object. 032 * 033 * @see <a href=https://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-03">draft-ietf-appsawg-json-pointer-03</a> 034 * @see NestedRegexFilter for more details. 035 */ 036public class JSONRegexFilter extends NestedRegexFilter 037 { 038 /** 039 * Creates a new JSONRegexFilter instance. 040 * 041 * @param pointer of String 042 * @param pattern of Pattern 043 */ 044 @ConstructorProperties({"pointer", "pattern"}) 045 public JSONRegexFilter( String pointer, Pattern pattern ) 046 { 047 this( pointer, Collections.singletonList( pattern ) ); 048 } 049 050 /** 051 * Creates a new JSONRegexFilter instance. 052 * 053 * @param pointer of String 054 * @param patterns of List 055 */ 056 @ConstructorProperties({"pointer", "patterns"}) 057 public JSONRegexFilter( String pointer, List<Pattern> patterns ) 058 { 059 super( JSONCoercibleType.TYPE, pointer, patterns, true ); 060 } 061 062 /** 063 * Creates a new JSONRegexFilter instance. 064 * 065 * @param coercibleType of JSONCoercibleType 066 * @param pointer of String 067 * @param pattern of Pattern 068 */ 069 @ConstructorProperties({"coercibleType", "pointer", "pattern"}) 070 public JSONRegexFilter( JSONCoercibleType coercibleType, String pointer, Pattern pattern ) 071 { 072 this( coercibleType, pointer, Collections.singletonList( pattern ) ); 073 } 074 075 /** 076 * Creates a new JSONRegexFilter instance. 077 * 078 * @param coercibleType of JSONCoercibleType 079 * @param pointer of String 080 * @param patterns of List 081 */ 082 @ConstructorProperties({"coercibleType", "pointer", "patterns"}) 083 public JSONRegexFilter( JSONCoercibleType coercibleType, String pointer, List<Pattern> patterns ) 084 { 085 super( coercibleType, pointer, patterns, true ); 086 } 087 088 /** 089 * Creates a new JSONRegexFilter instance. 090 * 091 * @param pointer of String 092 * @param pattern of Pattern 093 * @param failOnMissingNode of Boolean 094 */ 095 @ConstructorProperties({"pointer", "pattern", "failOnMissingNode"}) 096 public JSONRegexFilter( String pointer, Pattern pattern, boolean failOnMissingNode ) 097 { 098 this( pointer, Collections.singletonList( pattern ), failOnMissingNode ); 099 } 100 101 /** 102 * Creates a new JSONRegexFilter instance. 103 * 104 * @param pointer of String 105 * @param patterns of List 106 * @param failOnMissingNode of Boolean 107 */ 108 @ConstructorProperties({"pointer", "patterns", "failOnMissingNode"}) 109 public JSONRegexFilter( String pointer, List<Pattern> patterns, boolean failOnMissingNode ) 110 { 111 super( JSONCoercibleType.TYPE, pointer, patterns, failOnMissingNode ); 112 } 113 114 /** 115 * Creates a new JSONRegexFilter instance. 116 * 117 * @param coercibleType of JSONCoercibleType 118 * @param pointer of String 119 * @param pattern of Pattern 120 * @param failOnMissingNode of Boolean 121 */ 122 @ConstructorProperties({"coercibleType", "pointer", "pattern", "failOnMissingNode"}) 123 public JSONRegexFilter( JSONCoercibleType coercibleType, String pointer, Pattern pattern, boolean failOnMissingNode ) 124 { 125 this( coercibleType, pointer, Collections.singletonList( pattern ), failOnMissingNode ); 126 } 127 128 /** 129 * Creates a new JSONRegexFilter instance. 130 * 131 * @param coercibleType of JSONCoercibleType 132 * @param pointer of String 133 * @param patterns of List 134 * @param failOnMissingNode of Boolean 135 */ 136 @ConstructorProperties({"coercibleType", "pointer", "patterns", "failOnMissingNode"}) 137 public JSONRegexFilter( JSONCoercibleType coercibleType, String pointer, List<Pattern> patterns, boolean failOnMissingNode ) 138 { 139 super( coercibleType, pointer, patterns, failOnMissingNode ); 140 } 141 }