当前位置: 首页>>代码示例>>Java>>正文


Java Example类代码示例

本文整理汇总了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);

    }
 
开发者ID:MrBW,项目名称:resilient-transport-service,代码行数:21,代码来源:AddressService.java

示例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();
}
 
开发者ID:hexagonframework,项目名称:spring-data-ebean,代码行数:8,代码来源:SimpleEbeanRepository.java

示例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));
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:11,代码来源:JpaEventDao.java

示例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();
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:24,代码来源:QueryTests.java

示例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();
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:23,代码来源:QueryTests.java

示例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;
}
 
开发者ID:514840279,项目名称:danyuan-application,代码行数:24,代码来源:SysSeedServiceImpl.java

示例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);
}
 
开发者ID:514840279,项目名称:danyuan-application,代码行数:17,代码来源:SysSeedResultRulerServiceImpl.java

示例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);
}
 
开发者ID:hexagonframework,项目名称:spring-data-ebean,代码行数:32,代码来源:ExampleExpressionBuilder.java

示例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();
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:29,代码来源:QueryTests.java

示例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));
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:11,代码来源:JpaEventDao.java

示例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;
}
 
开发者ID:514840279,项目名称:danyuan-application,代码行数:19,代码来源:SysUserBaseServiceImpl.java

示例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));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:12,代码来源:UserRepositoryIntegrationTests.java

示例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));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:15,代码来源:UserRepositoryIntegrationTests.java

示例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));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:12,代码来源:UserRepositoryIntegrationTests.java

示例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));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:12,代码来源:UserRepositoryIntegrationTests.java


注:本文中的org.springframework.data.domain.Example类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。