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


Java PageMetadata类代码示例

本文整理汇总了Java中org.springframework.hateoas.PagedResources.PageMetadata的典型用法代码示例。如果您正苦于以下问题:Java PageMetadata类的具体用法?Java PageMetadata怎么用?Java PageMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PageMetadata类属于org.springframework.hateoas.PagedResources包,在下文中一共展示了PageMetadata类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPagedResources

import org.springframework.hateoas.PagedResources.PageMetadata; //导入依赖的package包/类
@Test
public void testPagedResources() {
    List<Address> addresses = new ArrayList<Address>();
    for (int i = 0; i < 4; i++) {
        addresses.add(new Address());
    }


    PagedResources<Address> addressResources = new PagedResources<Address>(addresses,
            new PageMetadata(2, 0, addresses.size()));
    addressResources.add(new Link("http://example.com/addresses", "self"));
    SirenEntity entity = new SirenEntity();
    sirenUtils.toSirenEntity(entity, addressResources);

    String json = objectMapper.valueToTree(entity)
            .toString();
    with(json).assertThat("$.entities", hasSize(4));
    with(json).assertThat("$.entities[0].properties.city.postalCode", equalTo("74199"));
    with(json).assertThat("$.entities[3].properties.city.name", equalTo("Donnbronn"));
    with(json).assertThat("$.links", hasSize(1));
}
 
开发者ID:dschulten,项目名称:hydra-java,代码行数:22,代码来源:SirenUtilsTest.java

示例2: discoverStoreSearch

import org.springframework.hateoas.PagedResources.PageMetadata; //导入依赖的package包/类
@Test
public void discoverStoreSearch() {

	Traverson traverson = new Traverson(URI.create(String.format(SERVICE_URI, port)), MediaTypes.HAL_JSON);

	// Set up path traversal
	TraversalBuilder builder = traverson. //
			follow("stores", "search", "by-location");

	// Log discovered
	log.info("");
	log.info("Discovered link: {}", builder.asTemplatedLink());
	log.info("");

	Map<String, Object> parameters = new HashMap<>();
	parameters.put("location", "40.740337,-73.995146");
	parameters.put("distance", "0.5miles");

	PagedResources<Resource<Store>> resources = builder.//
			withTemplateParameters(parameters).//
			toObject(new PagedResourcesType<Resource<Store>>() {});

	PageMetadata metadata = resources.getMetadata();

	log.info("Got {} of {} stores: ", resources.getContent().size(), metadata.getTotalElements());

	StreamSupport.stream(resources.spliterator(), false).//
			map(Resource::getContent).//
			forEach(store -> log.info("{} - {}", store.name, store.address));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:31,代码来源:StarbucksClient.java

示例3: getAll

import org.springframework.hateoas.PagedResources.PageMetadata; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.GET)
public PagedResources<Customer> getAll() {
	return new PagedResources<Customer>(Arrays.asList(new Customer(42,
			"Eberhard", "Wolff", "[email protected]",
			"Unter den Linden", "Berlin")), new PageMetadata(1, 0, 1));
}
 
开发者ID:ewolff,项目名称:microservice-cloudfoundry,代码行数:7,代码来源:CustomerStub.java

示例4: getAll

import org.springframework.hateoas.PagedResources.PageMetadata; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.GET)
public PagedResources<Item> getAll() {
	return new PagedResources<Item>(
			Arrays.asList(new Item(1, "iPod", 42.0)), new PageMetadata(1,
					0, 1));
}
 
开发者ID:ewolff,项目名称:microservice-cloudfoundry,代码行数:7,代码来源:CatalogStub.java

示例5: getMetadata

import org.springframework.hateoas.PagedResources.PageMetadata; //导入依赖的package包/类
public PageMetadata getMetadata() {
	return metadata;
}
 
开发者ID:Azure,项目名称:CityPower-Build-Sample,代码行数:4,代码来源:PagedIncidents.java

示例6: setMetadata

import org.springframework.hateoas.PagedResources.PageMetadata; //导入依赖的package包/类
public void setMetadata(PageMetadata metadata) {
	this.metadata = metadata;
}
 
开发者ID:Azure,项目名称:CityPower-Build-Sample,代码行数:4,代码来源:PagedIncidents.java


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