String clause; final ExampleMatcher.PropertySpecifier specifier = example.getMatcher().getPropertySpecifiers() .getForPath(fullPath); if (specifier != null && value != null) { value = specifier.transformValue(Optional.of(value)).orElse(null);
/** * This method will create an invocation that had it occurred on a query method would provide sufficient * data for a parsed query method expression to be evaluated * @param descriptor the query descriptor * @param example the example that is used for evaluation * @return the fake method invocation corresponding to the example probe */ private Invocation createInvocation(QueryDescriptor descriptor, Example example) { final List<Object> values = new ArrayList<>(); //since according to http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#query-by-example //the matcher only supports AND condition, so, we expect to see only one branch final List<List<Parameter>> branches = descriptor.getBranches(); final List<Parameter> parameters = branches.get(0); for (Parameter parameter : parameters) { final String propertyPath = parameter.getPath(); final Object propertyValue = PropertyUtils.getPropertyValue(example.getProbe(), propertyPath); final ExampleMatcher.PropertySpecifier specifier = example.getMatcher().getPropertySpecifiers().getForPath(propertyPath); values.add(specifier == null ? propertyValue : specifier.getPropertyValueTransformer().convert(propertyValue)); } return new ImmutableInvocation(null, values.toArray()); }
String clause; final ExampleMatcher.PropertySpecifier specifier = example.getMatcher().getPropertySpecifiers() .getForPath(fullPath); if (specifier != null && value != null) { value = specifier.transformValue(Optional.of(value)).orElse(null);
/** * This method will create an invocation that had it occurred on a query method would provide sufficient * data for a parsed query method expression to be evaluated * @param descriptor the query descriptor * @param example the example that is used for evaluation * @return the fake method invocation corresponding to the example probe */ private Invocation createInvocation(QueryDescriptor descriptor, Example example) { final List<Object> values = new ArrayList<>(); //since according to http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#query-by-example //the matcher only supports AND condition, so, we expect to see only one branch final List<List<Parameter>> branches = descriptor.getBranches(); final List<Parameter> parameters = branches.get(0); for (Parameter parameter : parameters) { final String propertyPath = parameter.getPath(); final Object propertyValue = PropertyUtils.getPropertyValue(example.getProbe(), propertyPath); final ExampleMatcher.PropertySpecifier specifier = example.getMatcher().getPropertySpecifiers().getForPath(propertyPath); values.add(specifier == null ? propertyValue : specifier.getPropertyValueTransformer().convert(propertyValue)); } return new ImmutableInvocation(null, values.toArray()); }
private boolean ignoreCase(ExampleMatcher matcher, String path) { final ExampleMatcher.PropertySpecifier specifier = matcher.getPropertySpecifiers().getForPath(path); return matcher.isIgnoreCaseEnabled() || specifier != null && Boolean.TRUE.equals(specifier.getIgnoreCase()); }
private ExampleMatcher.StringMatcher stringMatcher(ExampleMatcher matcher, String path) { final ExampleMatcher.PropertySpecifier specifier = matcher.getPropertySpecifiers().getForPath(path); return specifier != null ? specifier.getStringMatcher() : matcher.getDefaultStringMatcher(); }
/** * Get the {@link ExampleMatcher.PropertySpecifier} for given path. <br /> * Please check if {@link #hasPropertySpecifier(String)} to avoid running into {@literal null} values. * * @param path Dot-Path to property. * @return {@literal null} when no {@link ExampleMatcher.PropertySpecifier} defined for path. */ public ExampleMatcher.PropertySpecifier getPropertySpecifier(String path) { return matcher.getPropertySpecifiers().getForPath(path); }
private ExampleMatcher.StringMatcher stringMatcher(ExampleMatcher matcher, String path) { final ExampleMatcher.PropertySpecifier specifier = matcher.getPropertySpecifiers().getForPath(path); return specifier != null ? specifier.getStringMatcher() : matcher.getDefaultStringMatcher(); }
private boolean ignoreCase(ExampleMatcher matcher, String path) { final ExampleMatcher.PropertySpecifier specifier = matcher.getPropertySpecifiers().getForPath(path); return matcher.isIgnoreCaseEnabled() || specifier != null && Boolean.TRUE.equals(specifier.getIgnoreCase()); }
private PropertySpecifier getOrCreatePropertySpecifier(String propertyPath, PropertySpecifiers propertySpecifiers) { if (propertySpecifiers.hasSpecifierForPath(propertyPath)) { return propertySpecifiers.getForPath(propertyPath); } return new PropertySpecifier(propertyPath); } }