Refine search
public StringMatcher getDefaultStringMatcher() { return delegate.getDefaultStringMatcher(); }
public boolean isIgnoreCaseEnabled() { return delegate.isIgnoreCaseEnabled(); }
public static UntypedExampleMatcher matching() { return new UntypedExampleMatcher(ExampleMatcher.matching()); }
/** * Generates a list of {@link Developer} from a request. * * @param developerDTO The {@link DeveloperDTO} * @return The list of {@link Developer} */ public List<Developer> list(DeveloperDTO developerDTO) { Developer developer = GenericConverter.mapper(developerDTO, Developer.class); Example<Developer> example = Example.of(developer, ExampleMatcher.matching().withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); List<Developer> developers = developerRepository.findAll(example); return developers; }
/** * Generates a list of {@link Provider} from a request * * @param providerDTO The {@link ProviderDTO} * @return The list of {@link Provider} */ public List<Provider> listWithFilter(ProviderDTO providerDTO) { Provider provider = GenericConverter.mapper(providerDTO, Provider.class); Example<Provider> example = Example.of(provider, ExampleMatcher.matching().withIgnorePaths("providerDefault").withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); return this.providerRepository.findAll(example); }
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"); } } }
@Override public PageModel<User> findAll(User param, Pageable pageable) { ExampleMatcher matcher = ExampleMatcher.matching() .withMatcher("username", ExampleMatcher.GenericPropertyMatchers.contains()) .withMatcher("realName", ExampleMatcher.GenericPropertyMatchers.contains()) .withMatcher("email", ExampleMatcher.GenericPropertyMatchers.contains()) .withMatcher("mobile", ExampleMatcher.GenericPropertyMatchers.contains()); return new PageModel<>(baseDao.findAll(Example.of(param, matcher), pageable)); }
private void traversePropertyTree( final Example<T> example, final StringBuilder predicateBuilder, final Map<String, Object> bindVars, final String path, final String javaPath, final ArangoPersistentEntity<?> entity, final Object object) { final PersistentPropertyAccessor<?> accessor = entity.getPropertyAccessor(object); entity.doWithProperties((final ArangoPersistentProperty property) -> { if (property.getFrom().isPresent() || property.getTo().isPresent() || property.getRelations().isPresent()) { return; } final String fullPath = path + (path.length() == 0 ? "" : ".") + property.getFieldName(); final String fullJavaPath = javaPath + (javaPath.length() == 0 ? "" : ".") + property.getName(); final Object value = accessor.getProperty(property); if (property.isEntity() && value != null) { final ArangoPersistentEntity<?> persistentEntity = context.getPersistentEntity(property.getType()); traversePropertyTree(example, predicateBuilder, bindVars, fullPath, fullJavaPath, persistentEntity, value); } else if (!example.getMatcher().isIgnoredPath(fullJavaPath) && (value != null || example.getMatcher().getNullHandler().equals(ExampleMatcher.NullHandler.INCLUDE))) { addPredicate(example, predicateBuilder, bindVars, fullPath, fullJavaPath, value); } }); }
switch (example.getMatcher().getDefaultStringMatcher()) { case EXACT: likeType = LikeType.EQUAL_TO; example.getMatcher().isIgnoreCaseEnabled(), likeType);
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(); }
public PropertySpecifiers getPropertySpecifiers() { return delegate.getPropertySpecifiers(); }
public UntypedExampleMatcher withIgnoreCase(String... propertyPaths) { return new UntypedExampleMatcher(delegate.withIgnoreCase(propertyPaths)); }
public MatchMode getMatchMode() { return delegate.getMatchMode(); }
public UntypedExampleMatcher withMatcher(String propertyPath, MatcherConfigurer<GenericPropertyMatcher> matcherConfigurer) { return new UntypedExampleMatcher(delegate.withMatcher(propertyPath, matcherConfigurer)); }
public boolean isAllMatching() { return delegate.isAllMatching(); }
public boolean isIgnoredPath(String path) { return delegate.isIgnoredPath(path); }
public NullHandler getNullHandler() { return delegate.getNullHandler(); }
/** * Create a new {@link Example} including all non-null properties by default. * * @param probe must not be {@literal null}. * @return */ static <T> Example<T> of(T probe) { return new TypedExample<>(probe, ExampleMatcher.matching()); }
/** * Returns a copy of this {@link ExampleMatcher} with ignoring case sensitivity by default. This instance is immutable * and unaffected by this method call. * * @return new instance of {@link ExampleMatcher}. */ default ExampleMatcher withIgnoreCase() { return withIgnoreCase(true); }