本文整理匯總了Java中org.springframework.hateoas.PagedResources.getContent方法的典型用法代碼示例。如果您正苦於以下問題:Java PagedResources.getContent方法的具體用法?Java PagedResources.getContent怎麽用?Java PagedResources.getContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.hateoas.PagedResources
的用法示例。
在下文中一共展示了PagedResources.getContent方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: traversCustomerFindByFirstNameIT
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@Test
public void traversCustomerFindByFirstNameIT() {
//travers to findByFirstName
try {
final Map<String, Object> parameters = new HashMap<>();
parameters.put("firstName", "Donnie");
final Traverson traverson = new Traverson(new URI(BASE_URI), MediaTypes.HAL_JSON);
final PagedResources<Resource<Customer>> resources = traverson
.follow("customers", "search", "findByFirstName")
.withTemplateParameters(parameters)
.toObject(new TypeReferences.PagedResourcesType<Resource<Customer>>() {
});
assertThat(resources.getContent()).isNotNull();
assertThat(resources.getContent().size()).isEqualTo(1);
final List<Resource<Customer>> customers = new LinkedList<>(resources.getContent());
final Customer customer = customers.get(0).getContent();
assertThat(customer).isNotNull();
assertThat(customer.getFirstName()).isEqualTo("Donnie");
} catch (URISyntaxException e) {
fail(e.getMessage());
}
}
示例2: findAll
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@HystrixCommand(fallbackMethod = "getItemsCache", commandProperties = {
@HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "2") })
public Collection<Item> findAll() {
PagedResources<Item> pagedResources = restTemplate.getForObject(catalogURL(), ItemPagedResources.class);
this.itemsCache = pagedResources.getContent();
return pagedResources.getContent();
}
示例3: fromPagedResourceJson
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
/**
* Parses the given JSON string into a PagedResources object using a Jackson mapper configured for
* HAL type HATEOAS resources.
*
* @param json the JSON string to parse.
* @param contentType class of the type of the objects contained within the PagedResources
* wrapper.
* @param <T> the type of the objects contained within the PagedResources wrapper.
* @return a PagedResources object if parsing was successful.
* @throws IOException if the JSON string could not be parsed into an object of the given target
* type.
*/
@SuppressWarnings("unchecked")
public static <T> PagedResources<T> fromPagedResourceJson(String json, Class<T> contentType)
throws IOException {
List<T> contentItems = new ArrayList<>();
PagedResources<Map<String, Object>> pagedResources =
halMapper.readValue(json, PagedResources.class);
for (Map<String, Object> contentItem : pagedResources.getContent()) {
String objectJson = halMapper.writeValueAsString(contentItem);
T object = halMapper.readValue(objectJson, contentType);
contentItems.add(object);
}
return new PagedResources<>(contentItems, pagedResources.getMetadata());
}
示例4: getMetrics
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@HystrixCommand(fallbackMethod = "defaultMetrics")
public List<ApplicationsMetrics> getMetrics() {
List<ApplicationsMetrics> metrics = null;
if (StringUtils.hasText(this.collectorEndpoint)) {
try {
PagedResources<ApplicationsMetrics> response = restTemplate.exchange(this.collectorEndpoint,
HttpMethod.GET, null, new ParameterizedTypeReference<PagedResources<ApplicationsMetrics>>() {
}).getBody();
metrics = new ArrayList<>(response.getContent());
if (logger.isDebugEnabled()) {
logger.debug("Metrics = " + metrics);
}
}
catch (Exception e) {
if (e instanceof HttpClientErrorException && e.getMessage().startsWith("401")) {
logger.warn(String.format(
"Failure while requesting metrics from url '%s': '%s'. "
+ "Unauthorized, please provide valid credentials.",
this.collectorEndpoint, e.getMessage()));
}
else {
logger.warn(String.format("Failure while requesting metrics from url '%s': %s",
this.collectorEndpoint, e.getMessage()));
}
if (logger.isDebugEnabled()) {
logger.debug("The metrics request failed with:", e);
}
throw e;
}
}
else {
metrics = defaultMetrics();
}
return metrics;
}
示例5: fromPagedResourceJson
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
/**
* Parses the given JSON string into a PagedResources object using a Jackson mapper configured for
* HAL type HATEOAS resources.
*
* @param json the JSON string to parse.
* @param contentType class of the type of the objects contained within the PagedResources
* wrapper.
* @param <T> the type of the objects contained within the PagedResources wrapper.
* @return a PagedResources object if parsing was successful.
* @throws IOException if the JSON string could not be parsed into an object of the given target
* type.
*/
@SuppressWarnings("unchecked")
public static <T> PagedResources<T> fromPagedResourceJson(String json, Class<T> contentType)
throws IOException {
List<T> contentItems = new ArrayList<>();
PagedResources<Map<String, Object>> pagedResources =
halMapper.readValue(json, PagedResources.class);
for (Map<String, Object> contentItem : pagedResources.getContent()) {
String objectJson = halMapper.writeValueAsString(contentItem);
T object = halMapper.readValue(objectJson, contentType);
contentItems.add(object);
}
return new PagedResources<T>(contentItems, pagedResources.getMetadata());
}
示例6: listModules
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
public Collection<ModuleDefinitionResource> listModules(ModuleFilter moduleFilter) {
PagedResources<ModuleDefinitionResource> o = xdTemplate.moduleOperations().list(null);
List<ModuleDefinitionResource> results = new ArrayList<>();
for (ModuleDefinitionResource moduleDefinitionResource : o.getContent()) {
// System.out.println("Checking '" + moduleDefinitionResource.getName() + "' against filter");
if (moduleFilter.accept(moduleDefinitionResource)) {
results.add(moduleDefinitionResource);
}
}
return (results.size() == 0 ? Collections.emptyList() : results);
}
示例7: findAll
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
public Collection<Item> findAll() {
PagedResources<Item> pagedResources = restTemplate.getForObject(catalogURL(), ItemPagedResources.class);
return pagedResources.getContent();
}
示例8: findAll
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
public Collection<Customer> findAll() {
PagedResources<Customer> pagedResources = getRestTemplate().getForObject(customerURL(),
CustomerPagedResources.class);
return pagedResources.getContent();
}
示例9: PagedIncidents
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
public PagedIncidents(PagedResources<IncidentBean> beanResources,int pg) {
this.incidents = new ArrayList<IncidentBean>(beanResources.getContent());
this.metadata = beanResources.getMetadata();
this.page = pg;
}
示例10: findAll
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
public Collection<Item> findAll() {
PagedResources<Item> pagedResources = restTemplate.getForObject(
catalogURL(), ItemPagedResources.class);
return pagedResources.getContent();
}
示例11: findAll
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
public Collection<Customer> findAll() {
PagedResources<Customer> pagedResources = getRestTemplate()
.getForObject(customerURL(), CustomerPagedResources.class);
return pagedResources.getContent();
}