@Test public void paramStrTest() throws Exception { HashMap<String,String> map=new HashMap<>(); map.put("v1","value1"); map.put("v2","value2"); map.put("v3",null); String result=FindRequestBuilder. applyParameters("test ${v1}=${v2} and ${v3}, ${v4} ${v5",map); Assert.assertEquals("test value1=value2 and null, ${v4} ${v5",result); }
public static JsonNode applyParameters(JsonNode source,Map<String,String> parameters) { if(source instanceof ObjectNode) { return applyParameters( (ObjectNode) source, parameters); } else if(source instanceof ArrayNode) { return applyParameters( (ArrayNode)source, parameters); } else if(source instanceof TextNode) { String olds=source.asText(); String news=applyParameters(olds,parameters); if(olds!=news) { return JsonNodeFactory.instance.textNode(news); } else { return source; } } else { return source; } }
FindRequestBuilder { public static JsonNode applyParameters(JsonNode source,Map<String,String> parameters) { if(source instanceof ObjectNode) { return applyParameters( (ObjectNode) source, parameters); } else if(source instanceof ArrayNode) { return applyParameters( (ArrayNode)source, parameters); } else if(source instanceof TextNode) { String olds=source.asText(); String news=applyParameters(olds,parameters); if(olds!=news) { return JsonNodeFactory.instance.textNode(news); } else { return source; } } else { return source; } } }
FindRequestBuilder { public static JsonNode applyParameters(JsonNode source,Map<String,String> parameters) { if(source instanceof ObjectNode) { return applyParameters( (ObjectNode) source, parameters); } else if(source instanceof ArrayNode) { return applyParameters( (ArrayNode)source, parameters); } else if(source instanceof TextNode) { String olds=source.asText(); String news=applyParameters(olds,parameters); if(olds!=news) { return JsonNodeFactory.instance.textNode(news); } else { return source; } } else { return source; } }  }
FindRequestBuilder { public static JsonNode applyParameters(JsonNode source,Map<String,String> parameters) { if(source instanceof ObjectNode) { return applyParameters( (ObjectNode) source, parameters); } else if(source instanceof ArrayNode) { return applyParameters( (ArrayNode)source, parameters); } else if(source instanceof TextNode) { String olds=source.asText(); String news=applyParameters(olds,parameters); if(olds!=news) { return JsonNodeFactory.instance.textNode(news); } else { return source; } } else { return source; } }  static Map<String,String> fillDefaults(JsonNode savedSearch,
                                                  Map<String,String> parameterValues,
                                                  TypeResolver types); static FindRequest buildRequest(JsonNode savedSearch,
                                           String entity,
                                           String version,
                                           ClientIdentification clid,
                                           Map<String,String> parameterValues); static JsonNode applyParameters(JsonNode source,Map<String,String> parameters); static String applyParameters(String source,Map<String,String> parameters); }
FindRequestBuilder { public static JsonNode applyParameters(JsonNode source,Map<String,String> parameters) { if(source instanceof ObjectNode) { return applyParameters( (ObjectNode) source, parameters); } else if(source instanceof ArrayNode) { return applyParameters( (ArrayNode)source, parameters); } else if(source instanceof TextNode) { String olds=source.asText(); String news=applyParameters(olds,parameters); if(olds!=news) { return JsonNodeFactory.instance.textNode(news); } else { return source; } } else { return source; } }  static Map<String,String> fillDefaults(JsonNode savedSearch,
                                                  Map<String,String> parameterValues,
                                                  TypeResolver types); static FindRequest buildRequest(JsonNode savedSearch,
                                           String entity,
                                           String version,
                                           ClientIdentification clid,
                                           Map<String,String> parameterValues); static JsonNode applyParameters(JsonNode source,Map<String,String> parameters); static String applyParameters(String source,Map<String,String> parameters); static final String ERR_SAVED_SEARCH_INVALID_TYPE; static final String ERR_SAVED_SEARCH_NO_DEFAULT_VALUE; static final String ERR_SAVED_SEARCH_MISSING_PARAM; }