本文整理汇总了Java中org.springframework.data.domain.Example类的典型用法代码示例。如果您正苦于以下问题:Java Example类的具体用法?Java Example怎么用?Java Example使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Example类属于org.springframework.data.domain包,在下文中一共展示了Example类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateAddress
import org.springframework.data.domain.Example; //导入依赖的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);
}
示例2: findAll
import org.springframework.data.domain.Example; //导入依赖的package包/类
@Override
public <S extends T> List<S> findAll(Example<S> example, Sort sort) {
return db().find(example.getProbeType())
.where(ExampleExpressionBuilder.exampleExpression(db(), example))
.setOrder(Converters.convertToEbeanOrderBy(sort))
.findList();
}
示例3: findForUser
import org.springframework.data.domain.Example; //导入依赖的package包/类
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final String email) {
Event example = new Event();
CalendarUser cu = new CalendarUser();
cu.setEmail(email);
example.setOwner(cu);
return repository.findAll(Example.of(example));
}
示例4: testSingle
import org.springframework.data.domain.Example; //导入依赖的package包/类
@Test
public void testSingle() {
// tag::example-mono[]
Employee e = new Employee();
e.setFirstName("Bilbo");
Example<Employee> example = Example.of(e);
// end::example-mono[]
// tag::query-mono[]
Mono<Employee> singleEmployee = repository.findOne(example);
// end::query-mono[]
StepVerifier.create(singleEmployee)
.expectNextMatches(employee -> {
assertThat(employee).hasNoNullFieldsOrProperties();
assertThat(employee.getFirstName()).isEqualTo("Bilbo");
assertThat(employee.getLastName()).isEqualTo("Baggins");
assertThat(employee.getRole()).isEqualTo("burglar");
return true;
})
.expectComplete()
.verify();
}
示例5: testSingleWithTemplate
import org.springframework.data.domain.Example; //导入依赖的package包/类
@Test
public void testSingleWithTemplate() {
// tag::mono-template[]
Employee e = new Employee();
e.setFirstName("Bilbo");
Example<Employee> example = Example.of(e);
Mono<Employee> singleEmployee = operations.findOne(
new Query(byExample(example)), Employee.class);
// end::mono-template[]
StepVerifier.create(singleEmployee)
.expectNextMatches(employee -> {
assertThat(employee).hasNoNullFieldsOrProperties();
assertThat(employee.getFirstName()).isEqualTo("Bilbo");
assertThat(employee.getLastName()).isEqualTo("Baggins");
assertThat(employee.getRole()).isEqualTo("burglar");
return true;
})
.expectComplete()
.verify();
}
示例6: findAll
import org.springframework.data.domain.Example; //导入依赖的package包/类
/**
* 方法名 : findAll
* 功 能 : TODO(这里用一句话描述这个方法的作用)
* 参 数 : @return
* 参 考 : @see tk.ainiyue.admin.roles.service.SysRolesService#findAll()
* 作 者 : Tenghui.Wang
*/
@Override
public Page<SysSeedInfo> findAll(int pageNumber, int pageSize, String searchText) {
Sort sort = new Sort(new Order(Direction.DESC, "seedName"));
PageRequest request = this.buildPageRequest(pageNumber, pageSize, sort);
Page<SysSeedInfo> sourceCodes = null;
if (searchText == null || "".equals(searchText)) {
sourceCodes = sysSeedDao.findAll(request);
} else {
SysSeedInfo info = new SysSeedInfo();
info.setSeedName(searchText);
Example<SysSeedInfo> example = Example.of(info);
sourceCodes = sysSeedDao.findAll(example, request);
}
return sourceCodes;
}
示例7: saveSysSeedResultRulerInfo
import org.springframework.data.domain.Example; //导入依赖的package包/类
@Override
public List<SysSeedResultRulerInfo> saveSysSeedResultRulerInfo(SysSeedResultRulerVo vo) {
SysSeedResultRulerInfo info = new SysSeedResultRulerInfo();
info.setTableUuid(vo.getTableUuid());
info.setRulerUuid(vo.getRulerUuid());
Example<SysSeedResultRulerInfo> example = Example.of(info);
sysSeedResultRulerDao.delete(sysSeedResultRulerDao.findAll(example));
if (vo.getList() != null) {
for (SysSeedResultRulerInfo iterable_element : vo.getList()) {
iterable_element.setTableUuid(vo.getTableUuid());
iterable_element.setRulerUuid(vo.getRulerUuid());
sysSeedResultRulerDao.save(iterable_element);
}
}
return sysSeedResultRulerDao.findAll(example);
}
示例8: exampleExpression
import org.springframework.data.domain.Example; //导入依赖的package包/类
/**
* Return a ExampleExpression from Spring data Example
*
* @param ebeanServer
* @param example
* @param <T>
* @return
*/
public static <T> ExampleExpression exampleExpression(EbeanServer ebeanServer, Example<T> example) {
LikeType likeType;
switch (example.getMatcher().getDefaultStringMatcher()) {
case EXACT:
likeType = LikeType.EQUAL_TO;
break;
case CONTAINING:
likeType = LikeType.CONTAINS;
break;
case STARTING:
likeType = LikeType.STARTS_WITH;
break;
case ENDING:
likeType = LikeType.ENDS_WITH;
break;
default:
likeType = LikeType.RAW;
break;
}
return ebeanServer.getExpressionFactory().exampleLike(example.getProbe(),
example.getMatcher().isIgnoreCaseEnabled(),
likeType);
}
示例9: testMultiple
import org.springframework.data.domain.Example; //导入依赖的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();
}
示例10: findForUser
import org.springframework.data.domain.Example; //导入依赖的package包/类
@Override
@Transactional(readOnly = true)
public List<Event> findForUser(final int userId) {
Event example = new Event();
CalendarUser cu = new CalendarUser();
cu.setId(userId);
example.setOwner(cu);
return repository.findAll(Example.of(example));
}
示例11: findByName
import org.springframework.data.domain.Example; //导入依赖的package包/类
/**
* 方法名 : findByName
* 功 能 : TODO(这里用一句话描述这个方法的作用)
* 参 数 : @param userName
* 参 数 : @return
* 参 考 : @see
* tk.ainiyue.danyuan.application.user.userbase.service.SysUserBaseService#findByName(java.lang.String)
* 作 者 : Administrator
*/
@Override
public SysUserBaseInfo findByName(String userName) {
SysUserBaseInfo info = new SysUserBaseInfo();
info.setUserName(userName);
Example<SysUserBaseInfo> example = Example.of(info);
SysUserBaseInfo sourceCodes = sysUserBaseDao.findOne(example);
return sourceCodes;
}
示例12: substringMatching
import org.springframework.data.domain.Example; //导入依赖的package包/类
/**
* @see #153
*/
@Test
public void substringMatching() {
Example<User> example = Example.of(new User("er", null, null), matching().//
withStringMatcher(StringMatcher.ENDING));
assertThat(repository.findAll(example), hasItems(skyler, walter));
}
示例13: configuringMatchersUsingLambdas
import org.springframework.data.domain.Example; //导入依赖的package包/类
/**
* @see #153
*/
@Test
public void configuringMatchersUsingLambdas() {
Example<User> example = Example.of(new User("Walter", "WHITE", null),
matching().//
withIgnorePaths("age").//
withMatcher("firstname", matcher -> matcher.startsWith()).//
withMatcher("lastname", matcher -> matcher.ignoreCase()));
assertThat(repository.findAll(example), hasItems(flynn, walter));
}
示例14: ignorePropertiesAndMatchByAge
import org.springframework.data.domain.Example; //导入依赖的package包/类
/**
* @see #153
*/
@Test
public void ignorePropertiesAndMatchByAge() {
Example<Person> example = Example.of(flynn, matching(). //
withIgnorePaths("firstname", "lastname"));
assertThat(repository.findOne(example), is(flynn));
}
示例15: substringMatching
import org.springframework.data.domain.Example; //导入依赖的package包/类
/**
* @see #153
*/
@Test
public void substringMatching() {
Example<Person> example = Example.of(new Person("er", null, null), matching().//
withStringMatcher(StringMatcher.ENDING));
assertThat(repository.findAll(example), hasItems(skyler, walter));
}