本文整理汇总了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));
}
示例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));
}
示例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));
}
示例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));
}
示例5: getMetadata
import org.springframework.hateoas.PagedResources.PageMetadata; //导入依赖的package包/类
public PageMetadata getMetadata() {
return metadata;
}
示例6: setMetadata
import org.springframework.hateoas.PagedResources.PageMetadata; //导入依赖的package包/类
public void setMetadata(PageMetadata metadata) {
this.metadata = metadata;
}