public PropertySpecifiers getPropertySpecifiers() { return delegate.getPropertySpecifiers(); }
public PropertySpecifiers getPropertySpecifiers() { return delegate.getPropertySpecifiers(); }
/** * Returns whether the underlying {@link ExampleMatcher} contains a {@link PropertySpecifier} for the given path. * * @param path the dot-path identifying a property. * @return {@literal true} in case {@link ExampleMatcher.PropertySpecifier} defined for given path. */ public boolean hasPropertySpecifier(String path) { return matcher.getPropertySpecifiers().hasSpecifierForPath(path); }
/** * @return true if at least one {@link ExampleMatcher.PropertySpecifier} defined. */ public boolean hasPropertySpecifiers() { return matcher.getPropertySpecifiers().hasValues(); }
/** * Returns the {@link PropertySpecifier}s of the underlying {@link ExampleMatcher}. * * @return unmodifiable {@link Collection} of {@link ExampleMatcher.PropertySpecifier}s. */ public Collection<ExampleMatcher.PropertySpecifier> getPropertySpecifiers() { return matcher.getPropertySpecifiers().getSpecifiers(); }
/** * 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 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 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(); }
private ExampleMatcher.StringMatcher stringMatcher(ExampleMatcher matcher, String path) { final ExampleMatcher.PropertySpecifier specifier = matcher.getPropertySpecifiers().getForPath(path); return specifier != null ? specifier.getStringMatcher() : matcher.getDefaultStringMatcher(); }
/** * 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()); }
/** * 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 <T> void validateExample(Example<T> example) { Assert.notNull(example, "A non-null example is expected"); ExampleMatcher matcher = example.getMatcher(); if (!matcher.isAllMatching()) { throw new DatastoreDataException("Unsupported MatchMode. Only MatchMode.ALL is supported"); } if (matcher.isIgnoreCaseEnabled()) { throw new DatastoreDataException("Ignore case matching is not supported"); } if (!(matcher.getDefaultStringMatcher() == ExampleMatcher.StringMatcher.EXACT || matcher.getDefaultStringMatcher() == ExampleMatcher.StringMatcher.DEFAULT)) { throw new DatastoreDataException("Unsupported StringMatcher. Only EXACT and DEFAULT are supported"); } Optional<String> path = example.getMatcher().getIgnoredPaths().stream().filter((s) -> s.contains(".")).findFirst(); if (path.isPresent()) { throw new DatastoreDataException("Ignored paths deeper than 1 are not supported"); } if (matcher.getPropertySpecifiers().hasValues()) { throw new DatastoreDataException("Property matchers are not supported"); } } }
final ExampleMatcher.PropertySpecifier specifier = example.getMatcher().getPropertySpecifiers() .getForPath(fullPath); if (specifier != null && value != null) {
final ExampleMatcher.PropertySpecifier specifier = example.getMatcher().getPropertySpecifiers() .getForPath(fullPath); if (specifier != null && value != null) {