// Check if it is a "RealFilter"
JsonNode queryParam = root.get("queryParam");
if ( queryParam != null && queryParam.isValueNode() ) {
// pass in our objectCodec so that the subJsonParser knows about our configured Modules and Annotations
JsonParser subJsonParser = root.traverse( objectCodec );
return subJsonParser.readValueAs( RealFilter.class );
}
// We assume it is a LogicalFilter
Iterator<String> iter = root.fieldNames();
String key = iter.next();
JsonNode arrayNode = root.iterator().next();
if ( arrayNode == null || arrayNode.isMissingNode() || ! arrayNode.isArray() ) {
throw new RuntimeException( "Invalid format of LogicalFilter encountered." );
}
// pass in our objectCodec so that the subJsonParser knows about our configured Modules and Annotations
JsonParser subJsonParser = arrayNode.traverse( objectCodec );
List<QueryFilter> childrenQueryFilters = subJsonParser.readValueAs( new TypeReference<List<QueryFilter>>() {} );
return new LogicalFilter2( QueryParam.valueOf( key ), childrenQueryFilters );
}