@Test public void shouldProcessBuildValue3() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { Bar bar = new Bar( null, null, null, null, null, null, null, Collections.singletonList(new Foo(1L))); String res = tested.process(bar, "${id}_${list[0].id}_test"); Assert.assertEquals("null_1_test", res); }
protected String process(Object obj, String definition) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { StringBuffer value = new StringBuffer(definition); Pattern pattern = Pattern.compile("\\$\\{.+?\\}"); Matcher matcher = pattern.matcher(value); while (matcher.find()) { String path = matcher.group(); path = path.substring(2, path.length() - 1); String replacement = getPathValue(obj, path); value.replace(matcher.start(), matcher.end(), "" + replacement); matcher.reset(value); } return value.toString(); }
DefaultValueService { protected String process(Object obj, String definition) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { StringBuffer value = new StringBuffer(definition); Pattern pattern = Pattern.compile("\\$\\{.+?\\}"); Matcher matcher = pattern.matcher(value); while (matcher.find()) { String path = matcher.group(); path = path.substring(2, path.length() - 1); String replacement = getPathValue(obj, path); value.replace(matcher.start(), matcher.end(), "" + replacement); matcher.reset(value); } return value.toString(); } }
DefaultValueService { protected String process(Object obj, String definition) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { StringBuffer value = new StringBuffer(definition); Pattern pattern = Pattern.compile("\\$\\{.+?\\}"); Matcher matcher = pattern.matcher(value); while (matcher.find()) { String path = matcher.group(); path = path.substring(2, path.length() - 1); String replacement = getPathValue(obj, path); value.replace(matcher.start(), matcher.end(), "" + replacement); matcher.reset(value); } return value.toString(); } @Autowired  DefaultValueService(@NonNull final DefaultValueRepository repository,
                        @NonNull final ProjectRepository projectRepository); }
DefaultValueService { protected String process(Object obj, String definition) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { StringBuffer value = new StringBuffer(definition); Pattern pattern = Pattern.compile("\\$\\{.+?\\}"); Matcher matcher = pattern.matcher(value); while (matcher.find()) { String path = matcher.group(); path = path.substring(2, path.length() - 1); String replacement = getPathValue(obj, path); value.replace(matcher.start(), matcher.end(), "" + replacement); matcher.reset(value); } return value.toString(); } @Autowired  DefaultValueService(@NonNull final DefaultValueRepository repository,
                        @NonNull final ProjectRepository projectRepository); Map<String, Object> getValues(DefaultValue.DefaultValueType type, Long projectId); Map<String, Object> getValues(DefaultValue.DefaultValueType type, String projectSlug); void saveDefaultValues(@NonNull final Project project, @NonNull final U entity); }
DefaultValueService { protected String process(Object obj, String definition) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { StringBuffer value = new StringBuffer(definition); Pattern pattern = Pattern.compile("\\$\\{.+?\\}"); Matcher matcher = pattern.matcher(value); while (matcher.find()) { String path = matcher.group(); path = path.substring(2, path.length() - 1); String replacement = getPathValue(obj, path); value.replace(matcher.start(), matcher.end(), "" + replacement); matcher.reset(value); } return value.toString(); } @Autowired  DefaultValueService(@NonNull final DefaultValueRepository repository,
                        @NonNull final ProjectRepository projectRepository); Map<String, Object> getValues(DefaultValue.DefaultValueType type, Long projectId); Map<String, Object> getValues(DefaultValue.DefaultValueType type, String projectSlug); void saveDefaultValues(@NonNull final Project project, @NonNull final U entity);  }