本文整理汇总了Java中org.springframework.data.domain.ExampleMatcher类的典型用法代码示例。如果您正苦于以下问题:Java ExampleMatcher类的具体用法?Java ExampleMatcher怎么用?Java ExampleMatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExampleMatcher类属于org.springframework.data.domain包,在下文中一共展示了ExampleMatcher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: validateAddress
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
public Address validateAddress(AddressDTO addressDTO) {
Address addressToSearch = new Address(addressDTO.getCountry(), addressDTO.getCity(), addressDTO.getPostcode(),
addressDTO.getStreet(), addressDTO.getStreetNumber());
//@formatter:off
ExampleMatcher matcher =
ExampleMatcher.matching()
.withMatcher("country", startsWith().ignoreCase())
.withMatcher("postcode", startsWith().ignoreCase())
.withMatcher("street", contains().ignoreCase())
.withMatcher("streetNumber", contains().ignoreCase())
.withMatcher("city", contains().ignoreCase());
//@formatter:on
Example<Address> searchExample = Example.of(addressToSearch, matcher);
return addressRepository.findOne(searchExample);
}
开发者ID:MrBW,项目名称:resilient-transport-service,代码行数:21,代码来源:AddressService.java
示例2: savePosts
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
/**
* Saves a collection of posts.
*
* @param posts A list of posts.
*/
protected void savePosts(List<Post> posts) {
int inserted = 0;
for (Post p : posts) {
ExampleMatcher matcher = ExampleMatcher.matching()
.withMatcher("url", ExampleMatcher.GenericPropertyMatchers.exact());
if (!postRepository.exists(Example.of(p, matcher))) {
logger.info("Inserting " + p.getUrl());
savePost(p);
inserted++;
} else {
logger.info("Duplicate post. Not inserted " + p.getUrl());
}
}
logger.info("Inserted " + inserted + " items");
}
开发者ID:BakkerTom,项目名称:happy-news,代码行数:24,代码来源:Crawler.java
示例3: testFindByExample
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
@Test
public void testFindByExample() {
User u = new User();
u.setEmailAddress("YUANXUEGUI");
List<User> result1 = repository.findAll(Example.of(u, ExampleMatcher.matchingAll()
.withIgnoreCase(true)
.withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING)));
assertEquals(1, result1.size());
assertEquals("Yuan", result1.get(0).getFullName().getLastName());
assertThat(result1, hasItem(user));
List<User> result2 = repository.findAll(Example.of(u, ExampleMatcher.matchingAll()
.withIgnoreCase(false)
.withStringMatcher(ExampleMatcher.StringMatcher.EXACT)));
assertEquals(0, result2.size());
}
开发者ID:hexagonframework,项目名称:spring-data-ebean,代码行数:17,代码来源:UserRepositoryIntegrationTests.java
示例4: testExample
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
@Test
public void testExample() {
UserEntity admin = new UserEntity();
admin.setUserName("example");
admin.setLoginName("example");
admin.setPassword(BCryptPassWordUtils.encode("example"));
admin.setEmail("[email protected]");
ExampleMatcher matcher = ExampleMatcher.matching()
.withMatcher("userName", endsWith())
.withMatcher("loginName", startsWith().ignoreCase());
Example<UserEntity> example = Example.of(admin, matcher);
MyFastJsonUtils.prettyPrint(userRepository.findAll(example));
System.out.println(userRepository.count(example));
}
开发者ID:h819,项目名称:spring-boot,代码行数:20,代码来源:UserRepositoryTest.java
示例5: findAll
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
@Transactional(readOnly = true)
public PageResponse<UseCase1DTO> findAll(PageRequestByExample<UseCase1DTO> req) {
Example<UseCase1> example = null;
UseCase1 useCase1 = toEntity(req.example);
if (useCase1 != null) {
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(UseCase1_.dummy.getName(), match -> match.ignoreCase().startsWith());
example = Example.of(useCase1, matcher);
}
Page<UseCase1> page;
if (example != null) {
page = useCase1Repository.findAll(example, req.toPageable());
} else {
page = useCase1Repository.findAll(req.toPageable());
}
List<UseCase1DTO> content = page.getContent().stream().map(this::toDTO).collect(Collectors.toList());
return new PageResponse<>(page.getTotalPages(), page.getTotalElements(), content);
}
开发者ID:jaxio,项目名称:celerio-angular-quickstart,代码行数:23,代码来源:UseCase1DTOService.java
示例6: findAll
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
@Transactional(readOnly = true)
public PageResponse<RoleDTO> findAll(PageRequestByExample<RoleDTO> req) {
Example<Role> example = null;
Role role = toEntity(req.example);
if (role != null) {
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(Role_.roleName.getName(), match -> match.ignoreCase().startsWith());
example = Example.of(role, matcher);
}
Page<Role> page;
if (example != null) {
page = roleRepository.findAll(example, req.toPageable());
} else {
page = roleRepository.findAll(req.toPageable());
}
List<RoleDTO> content = page.getContent().stream().map(this::toDTO).collect(Collectors.toList());
return new PageResponse<>(page.getTotalPages(), page.getTotalElements(), content);
}
开发者ID:jaxio,项目名称:celerio-angular-quickstart,代码行数:23,代码来源:RoleDTOService.java
示例7: findAll
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
@Transactional(readOnly = true)
public PageResponse<PassportDTO> findAll(PageRequestByExample<PassportDTO> req) {
Example<Passport> example = null;
Passport passport = toEntity(req.example);
if (passport != null) {
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(Passport_.passportNumber.getName(), match -> match.ignoreCase().startsWith());
example = Example.of(passport, matcher);
}
Page<Passport> page;
if (example != null) {
page = passportRepository.findAll(example, req.toPageable());
} else {
page = passportRepository.findAll(req.toPageable());
}
List<PassportDTO> content = page.getContent().stream().map(this::toDTO).collect(Collectors.toList());
return new PageResponse<>(page.getTotalPages(), page.getTotalElements(), content);
}
开发者ID:jaxio,项目名称:celerio-angular-quickstart,代码行数:23,代码来源:PassportDTOService.java
示例8: findAll
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
@Transactional(readOnly = true)
public PageResponse<UseCase3DTO> findAll(PageRequestByExample<UseCase3DTO> req) {
Example<UseCase3> example = null;
UseCase3 useCase3 = toEntity(req.example);
if (useCase3 != null) {
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(UseCase3_.dummy.getName(), match -> match.ignoreCase().startsWith());
example = Example.of(useCase3, matcher);
}
Page<UseCase3> page;
if (example != null) {
page = useCase3Repository.findAll(example, req.toPageable());
} else {
page = useCase3Repository.findAll(req.toPageable());
}
List<UseCase3DTO> content = page.getContent().stream().map(this::toDTO).collect(Collectors.toList());
return new PageResponse<>(page.getTotalPages(), page.getTotalElements(), content);
}
开发者ID:jaxio,项目名称:celerio-angular-quickstart,代码行数:23,代码来源:UseCase3DTOService.java
示例9: findAll
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
@Transactional(readOnly = true)
public PageResponse<UserDTO> findAll(PageRequestByExample<UserDTO> req) {
Example<User> example = null;
User user = toEntity(req.example);
if (user != null) {
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(User_.login.getName(), match -> match.ignoreCase().startsWith())
.withMatcher(User_.email.getName(), match -> match.ignoreCase().startsWith())
.withMatcher(User_.firstName.getName(), match -> match.ignoreCase().startsWith())
.withMatcher(User_.lastName.getName(), match -> match.ignoreCase().startsWith());
example = Example.of(user, matcher);
}
Page<User> page;
if (example != null) {
page = userRepository.findAll(example, req.toPageable());
} else {
page = userRepository.findAll(req.toPageable());
}
List<UserDTO> content = page.getContent().stream().map(this::toDTO).collect(Collectors.toList());
return new PageResponse<>(page.getTotalPages(), page.getTotalElements(), content);
}
开发者ID:jaxio,项目名称:celerio-angular-quickstart,代码行数:26,代码来源:UserDTOService.java
示例10: findAll
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
@Transactional(readOnly = true)
public PageResponse<AuthorDTO> findAll(PageRequestByExample<AuthorDTO> req) {
Example<Author> example = null;
Author author = toEntity(req.example);
if (author != null) {
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(Author_.lastName.getName(), match -> match.ignoreCase().startsWith())
.withMatcher(Author_.firstName.getName(), match -> match.ignoreCase().startsWith())
.withMatcher(Author_.email.getName(), match -> match.ignoreCase().startsWith());
example = Example.of(author, matcher);
}
Page<Author> page;
if (example != null) {
page = authorRepository.findAll(example, req.toPageable());
} else {
page = authorRepository.findAll(req.toPageable());
}
List<AuthorDTO> content = page.getContent().stream().map(this::toDTO).collect(Collectors.toList());
return new PageResponse<>(page.getTotalPages(), page.getTotalElements(), content);
}
开发者ID:jaxio,项目名称:celerio-angular-quickstart,代码行数:25,代码来源:AuthorDTOService.java
示例11: findAll
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
@Transactional(readOnly = true)
public PageResponse<ProjectDTO> findAll(PageRequestByExample<ProjectDTO> req) {
Example<Project> example = null;
Project project = toEntity(req.example);
if (project != null) {
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(Project_.name.getName(), match -> match.ignoreCase().startsWith())
.withMatcher(Project_.url.getName(), match -> match.ignoreCase().startsWith());
example = Example.of(project, matcher);
}
Page<Project> page;
if (example != null) {
page = projectRepository.findAll(example, req.toPageable());
} else {
page = projectRepository.findAll(req.toPageable());
}
List<ProjectDTO> content = page.getContent().stream().map(this::toDTO).collect(Collectors.toList());
return new PageResponse<>(page.getTotalPages(), page.getTotalElements(), content);
}
开发者ID:jaxio,项目名称:celerio-angular-quickstart,代码行数:24,代码来源:ProjectDTOService.java
示例12: findAll
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
@Transactional(readOnly = true)
public PageResponse<UseCase2DTO> findAll(PageRequestByExample<UseCase2DTO> req) {
Example<UseCase2> example = null;
UseCase2 useCase2 = toEntity(req.example);
if (useCase2 != null) {
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(UseCase2_.dummy.getName(), match -> match.ignoreCase().startsWith());
example = Example.of(useCase2, matcher);
}
Page<UseCase2> page;
if (example != null) {
page = useCase2Repository.findAll(example, req.toPageable());
} else {
page = useCase2Repository.findAll(req.toPageable());
}
List<UseCase2DTO> content = page.getContent().stream().map(this::toDTO).collect(Collectors.toList());
return new PageResponse<>(page.getTotalPages(), page.getTotalElements(), content);
}
开发者ID:jaxio,项目名称:celerio-angular-quickstart,代码行数:23,代码来源:UseCase2DTOService.java
示例13: findAll
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
@Transactional(readOnly = true)
public PageResponse<BookDTO> findAll(PageRequestByExample<BookDTO> req) {
Example<Book> example = null;
Book book = toEntity(req.example);
if (book != null) {
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(Book_.title.getName(), match -> match.ignoreCase().startsWith())
.withMatcher(Book_.summary.getName(), match -> match.ignoreCase().startsWith());
example = Example.of(book, matcher);
}
Page<Book> page;
if (example != null) {
page = bookRepository.findAll(example, req.toPageable());
} else {
page = bookRepository.findAll(req.toPageable());
}
List<BookDTO> content = page.getContent().stream().map(this::toDTO).collect(Collectors.toList());
return new PageResponse<>(page.getTotalPages(), page.getTotalElements(), content);
}
开发者ID:jaxio,项目名称:celerio-angular-quickstart,代码行数:24,代码来源:BookDTOService.java
示例14: testMultiple
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
@Test
public void testMultiple() {
// tag::example-flux[]
Employee e = new Employee();
e.setLastName("baggins"); // Lowercase lastName
ExampleMatcher matcher = ExampleMatcher.matching()
.withIgnoreCase()
.withMatcher("lastName", startsWith())
.withIncludeNullValues();
Example<Employee> example = Example.of(e, matcher);
// end::example-flux[]
// tag::query-flux[]
Flux<Employee> multipleEmployees = repository.findAll(example);
// end::query-flux[]
StepVerifier.create(multipleEmployees.collectList())
.expectNextMatches(employees -> {
assertThat(employees).hasSize(2);
assertThat(employees).extracting("firstName")
.contains("Frodo", "Bilbo");
return true;
})
.expectComplete()
.verify();
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:29,代码来源:QueryTests.java
示例15: testMultipleWithTemplate
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
@Test
public void testMultipleWithTemplate() {
// tag::flux-template[]
Employee e = new Employee();
e.setLastName("baggins"); // Lowercase lastName
ExampleMatcher matcher = ExampleMatcher.matching()
.withIgnoreCase()
.withMatcher("lastName", startsWith())
.withIncludeNullValues();
Example<Employee> example = Example.of(e, matcher);
Flux<Employee> multipleEmployees = operations.find(
new Query(byExample(example)), Employee.class);
// end::flux-template[]
StepVerifier.create(multipleEmployees.collectList())
.expectNextMatches(employees -> {
assertThat(employees).hasSize(2);
assertThat(employees).extracting("firstName")
.contains("Frodo", "Bilbo");
return true;
})
.expectComplete()
.verify();
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:28,代码来源:QueryTests.java
示例16: testFindByFoodNameWithExampleMatchers
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
@Test
public void testFindByFoodNameWithExampleMatchers(){
ExampleMatcher matcher = ExampleMatcher.matching()
.withIgnorePaths("id")
.withIgnorePaths("transactionDate");
Example<Eats> example = Example.of(eat, matcher);
List<Eats> response = eatsRepository.findByFoodName(testFood);
Eats responseExample = Example.of(response.get(0), matcher).getProbe();
log.info("response: " + responseExample.toString());
log.info("repo: " + eatsRepository.findOne(example));
assert(eatsRepository.findOne(example).equals(responseExample));
}
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:13,代码来源:EatsRepositoryTest.java
示例17: complete
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
default List<UseCase1> complete(String query, int maxResults) {
UseCase1 probe = new UseCase1();
probe.setDummy(query);
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(UseCase1_.dummy.getName(), match -> match.ignoreCase().startsWith());
Page<UseCase1> page = findAll(Example.of(probe, matcher), new PageRequest(0, maxResults));
return page.getContent();
}
开发者ID:jaxio,项目名称:celerio-angular-quickstart,代码行数:11,代码来源:UseCase1Repository.java
示例18: complete
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
default List<Book> complete(String query, int maxResults) {
Book probe = new Book();
probe.setTitle(query);
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(Book_.title.getName(), match -> match.ignoreCase().startsWith());
Page<Book> page = findAll(Example.of(probe, matcher), new PageRequest(0, maxResults));
return page.getContent();
}
开发者ID:jaxio,项目名称:celerio-angular-quickstart,代码行数:11,代码来源:BookRepository.java
示例19: complete
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
default List<UseCase3> complete(String query, int maxResults) {
UseCase3 probe = new UseCase3();
probe.setDummy(query);
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(UseCase3_.dummy.getName(), match -> match.ignoreCase().startsWith());
Page<UseCase3> page = findAll(Example.of(probe, matcher), new PageRequest(0, maxResults));
return page.getContent();
}
开发者ID:jaxio,项目名称:celerio-angular-quickstart,代码行数:11,代码来源:UseCase3Repository.java
示例20: complete
import org.springframework.data.domain.ExampleMatcher; //导入依赖的package包/类
default List<UseCase2> complete(String query, int maxResults) {
UseCase2 probe = new UseCase2();
probe.setDummy(query);
ExampleMatcher matcher = ExampleMatcher.matching() //
.withMatcher(UseCase2_.dummy.getName(), match -> match.ignoreCase().startsWith());
Page<UseCase2> page = findAll(Example.of(probe, matcher), new PageRequest(0, maxResults));
return page.getContent();
}
开发者ID:jaxio,项目名称:celerio-angular-quickstart,代码行数:11,代码来源:UseCase2Repository.java
注:本文中的org.springframework.data.domain.ExampleMatcher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论