當前位置: 首頁>>代碼示例>>Java>>正文


Java PagedResources.getContent方法代碼示例

本文整理匯總了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());
    }

}
 
開發者ID:tuxdevelop,項目名稱:spring-data-repositories,代碼行數:24,代碼來源:CustomerRepositoryDataRestIT.java

示例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();
}
 
開發者ID:ewolff,項目名稱:microservice-cloudfoundry,代碼行數:8,代碼來源:CatalogClient.java

示例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());
}
 
開發者ID:reflectoring,項目名稱:infiniboard,代碼行數:26,代碼來源:JsonHelper.java

示例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;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-dataflow,代碼行數:36,代碼來源:MetricStore.java

示例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());
}
 
開發者ID:reflectoring,項目名稱:coderadar,代碼行數:26,代碼來源:JsonHelper.java

示例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);
}
 
開發者ID:aclement,項目名稱:spring-xd-fluent,代碼行數:12,代碼來源:XDRestClient.java

示例7: findAll

import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
public Collection<Item> findAll() {
	PagedResources<Item> pagedResources = restTemplate.getForObject(catalogURL(), ItemPagedResources.class);
	return pagedResources.getContent();
}
 
開發者ID:ewolff,項目名稱:microservice-cloudfoundry,代碼行數:5,代碼來源:CatalogClient.java

示例8: findAll

import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
public Collection<Customer> findAll() {
	PagedResources<Customer> pagedResources = getRestTemplate().getForObject(customerURL(),
			CustomerPagedResources.class);
	return pagedResources.getContent();
}
 
開發者ID:ewolff,項目名稱:microservice-cloudfoundry,代碼行數:6,代碼來源:CustomerClient.java

示例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;
}
 
開發者ID:Azure,項目名稱:CityPower-Build-Sample,代碼行數:6,代碼來源:PagedIncidents.java

示例10: findAll

import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
public Collection<Item> findAll() {
	PagedResources<Item> pagedResources = restTemplate.getForObject(
			catalogURL(), ItemPagedResources.class);
	return pagedResources.getContent();
}
 
開發者ID:ewolff,項目名稱:microservice-consul,代碼行數:6,代碼來源:CatalogClient.java

示例11: findAll

import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
public Collection<Customer> findAll() {
	PagedResources<Customer> pagedResources = getRestTemplate()
			.getForObject(customerURL(), CustomerPagedResources.class);
	return pagedResources.getContent();
}
 
開發者ID:ewolff,項目名稱:microservice-consul,代碼行數:6,代碼來源:CustomerClient.java


注:本文中的org.springframework.hateoas.PagedResources.getContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。