本文整理汇总了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());
}
示例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());
}
示例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());
}
示例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());
}