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


Java Page.hasContent方法代碼示例

本文整理匯總了Java中org.springframework.data.domain.Page.hasContent方法的典型用法代碼示例。如果您正苦於以下問題:Java Page.hasContent方法的具體用法?Java Page.hasContent怎麽用?Java Page.hasContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.data.domain.Page的用法示例。


在下文中一共展示了Page.hasContent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findInstancesByNamespace

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
public Page<Instance> findInstancesByNamespace(String appId, String clusterName, String
    namespaceName, Pageable pageable) {
  Page<InstanceConfig> instanceConfigs = instanceConfigRepository.
      findByConfigAppIdAndConfigClusterNameAndConfigNamespaceNameAndDataChangeLastModifiedTimeAfter(appId, clusterName,
          namespaceName, getValidInstanceConfigDate(), pageable);

  List<Instance> instances = Collections.emptyList();
  if (instanceConfigs.hasContent()) {
    Set<Long> instanceIds = instanceConfigs.getContent().stream().map
        (InstanceConfig::getInstanceId).collect(Collectors.toSet());
    instances = findInstancesByIds(instanceIds);
  }

  return new PageImpl<>(instances, pageable, instanceConfigs.getTotalElements());
}
 
開發者ID:dewey-its,項目名稱:apollo-custom,代碼行數:16,代碼來源:InstanceService.java

示例2: findInstancesByNamespaceAndInstanceAppId

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
public Page<Instance> findInstancesByNamespaceAndInstanceAppId(String instanceAppId, String
    appId, String clusterName, String
                                                                   namespaceName, Pageable
                                                                   pageable) {
  Page<Object[]> instanceIdResult = instanceConfigRepository
      .findInstanceIdsByNamespaceAndInstanceAppId(instanceAppId, appId, clusterName,
          namespaceName, getValidInstanceConfigDate(), pageable);

  List<Instance> instances = Collections.emptyList();
  if (instanceIdResult.hasContent()) {
    Set<Long> instanceIds = instanceIdResult.getContent().stream().map((Object o) -> {
      if (o == null) {
        return null;
      }

      if (o instanceof Integer) {
        return ((Integer)o).longValue();
      }

      if (o instanceof Long) {
        return (Long) o;
      }

      //for h2 test
      if (o instanceof BigInteger) {
        return ((BigInteger) o).longValue();
      }

      return null;
    }).filter((Long value) -> value != null).collect(Collectors.toSet());
    instances = findInstancesByIds(instanceIds);
  }

  return new PageImpl<>(instances, pageable, instanceIdResult.getTotalElements());
}
 
開發者ID:dewey-its,項目名稱:apollo-custom,代碼行數:36,代碼來源:InstanceService.java

示例3: transform2PageDTO

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
private PageDTO<ReleaseHistoryDTO> transform2PageDTO(Page<ReleaseHistory> releaseHistoriesPage, Pageable pageable){
  if (!releaseHistoriesPage.hasContent()) {
    return null;
  }

  List<ReleaseHistory> releaseHistories = releaseHistoriesPage.getContent();
  List<ReleaseHistoryDTO> releaseHistoryDTOs = new ArrayList<>(releaseHistories.size());
  for (ReleaseHistory releaseHistory : releaseHistories) {
    releaseHistoryDTOs.add(transformReleaseHistory2DTO(releaseHistory));
  }

  return new PageDTO<>(releaseHistoryDTOs, pageable, releaseHistoriesPage.getTotalElements());
}
 
開發者ID:dewey-its,項目名稱:apollo-custom,代碼行數:14,代碼來源:ReleaseHistoryController.java

示例4: getByRelease

import org.springframework.data.domain.Page; //導入方法依賴的package包/類
@RequestMapping(value = "/by-release", method = RequestMethod.GET)
public PageDTO<InstanceDTO> getByRelease(@RequestParam("releaseId") long releaseId,
                                         Pageable pageable) {
  Release release = releaseService.findOne(releaseId);
  if (release == null) {
    throw new NotFoundException(String.format("release not found for %s", releaseId));
  }
  Page<InstanceConfig> instanceConfigsPage = instanceService.findActiveInstanceConfigsByReleaseKey
      (release.getReleaseKey(), pageable);

  List<InstanceDTO> instanceDTOs = Collections.emptyList();

  if (instanceConfigsPage.hasContent()) {
    Multimap<Long, InstanceConfig> instanceConfigMap = HashMultimap.create();
    Set<String> otherReleaseKeys = Sets.newHashSet();

    for (InstanceConfig instanceConfig : instanceConfigsPage.getContent()) {
      instanceConfigMap.put(instanceConfig.getInstanceId(), instanceConfig);
      otherReleaseKeys.add(instanceConfig.getReleaseKey());
    }

    Set<Long> instanceIds = instanceConfigMap.keySet();

    List<Instance> instances = instanceService.findInstancesByIds(instanceIds);

    if (!CollectionUtils.isEmpty(instances)) {
      instanceDTOs = BeanUtils.batchTransform(InstanceDTO.class, instances);
    }

    for (InstanceDTO instanceDTO : instanceDTOs) {
      Collection<InstanceConfig> configs = instanceConfigMap.get(instanceDTO.getId());
      List<InstanceConfigDTO> configDTOs = configs.stream().map(instanceConfig -> {
        InstanceConfigDTO instanceConfigDTO = new InstanceConfigDTO();
        //to save some space
        instanceConfigDTO.setRelease(null);
        instanceConfigDTO.setReleaseDeliveryTime(instanceConfig.getReleaseDeliveryTime());
        instanceConfigDTO.setDataChangeLastModifiedTime(instanceConfig
            .getDataChangeLastModifiedTime());
        return instanceConfigDTO;
      }).collect(Collectors.toList());
      instanceDTO.setConfigs(configDTOs);
    }
  }

  return new PageDTO<>(instanceDTOs, pageable, instanceConfigsPage.getTotalElements());
}
 
開發者ID:dewey-its,項目名稱:apollo-custom,代碼行數:47,代碼來源:InstanceConfigController.java


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