Java Code Examples for org.apache.commons.collections4.CollectionUtils#isNotEmpty()
The following examples show how to use
org.apache.commons.collections4.CollectionUtils#isNotEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AutowiredProcessor.java From DDComponentForAndroid with Apache License 2.0 | 6 votes |
@Override public boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnvironment) { if (CollectionUtils.isNotEmpty(set)) { try { logger.info(">>> Found autowired field, start... <<<"); categories(roundEnvironment.getElementsAnnotatedWith(Autowired.class)); generateHelper(); } catch (Exception e) { logger.error(e); } return true; } return false; }
Example 2
Source File: FlowDependencyServiceImpl.java From liteflow with Apache License 2.0 | 6 votes |
@Override public List<TaskDependency> getDependencies(long flowId) { FlowDependencyQM qm = new FlowDependencyQM(); qm.setFlowId(flowId); List<FlowDependency> flowDependencies = flowDependencyMapper.findList(qm); if(CollectionUtils.isNotEmpty(flowDependencies)){ List<TaskDependency> taskDependencies = Lists.newArrayList(); for(FlowDependency flowDependency : flowDependencies){ TaskDependency taskDependency = taskDependencyService.getById(flowDependency.getTaskDependencyId()); taskDependencies.add(taskDependency); } return taskDependencies; } return null; }
Example 3
Source File: FlowServiceImpl.java From liteflow with Apache License 2.0 | 6 votes |
@Override public Set<Long> getFlowIdSetByTask(long taskId) { /** * 获取上线的任务流 */ Set<Long> flowIdSet = Sets.newHashSet(); Set<Long> taskFlowIdSet = this.getOnlineFlowIdSet(taskId); if(CollectionUtils.isNotEmpty(taskFlowIdSet)){ flowIdSet.addAll(taskFlowIdSet); } /** * 获取任务所属的未上线的任务流 */ Set<Long> unOnlineFlowIdSet = this.getUnOnlineFlowIdSet(taskId); if(CollectionUtils.isNotEmpty(unOnlineFlowIdSet)){ flowIdSet.addAll(unOnlineFlowIdSet); } return flowIdSet; }
Example 4
Source File: FlowServiceImpl.java From liteflow with Apache License 2.0 | 6 votes |
private Tuple<Set<Long>, Set<Long>> getSharedAndUnique(long flowId){ //共享的依赖 Set<Long> sharedDependency = Sets.newHashSet(); //仅仅属于当前任务流的依赖 Set<Long> flowUniqueDependency = Sets.newHashSet(); /** * 任务流原来的依赖关系 * 1.筛选出共享依赖和独享依赖 */ List<FlowDependency> flowOriginalDependencies = flowDependencyService.getFlowDependencies(flowId); if (CollectionUtils.isNotEmpty(flowOriginalDependencies)) { for (FlowDependency flowDependency : flowOriginalDependencies) { if (flowDependencyService.isFlowUnique(flowDependency.getTaskDependencyId(), flowId)) { flowUniqueDependency.add(flowDependency.getTaskDependencyId()); } else { sharedDependency.add(flowDependency.getTaskDependencyId()); } } } return new Tuple<>(sharedDependency, flowUniqueDependency); }
Example 5
Source File: PermissionResourceServiceImpl.java From spring-boot-start-current with Apache License 2.0 | 6 votes |
@Override @CacheEvict( value = GlobalCacheConstant.USER_DETAILS_SERVICE_NAMESPACE, allEntries = true, condition = "#result != null" ) public boolean deleteRelatePermissionResource ( List< PermissionResourceVO > vos ) { final List< Long > resourceIds = vos.parallelStream() .map( PermissionResourceVO::getId ) .collect( Collectors.toList() ); // 删除资源 AssertUtils.isTrue( ! super.removeByIds( resourceIds ) , "资源删除失败" ); // 删除相关角色资源中间表信息 final List< Object > middleIds = rolePermissionResourceService.listObjs( new QueryWrapper< RolePermissionResource >().in( "permission_resource_id" , resourceIds ) .select( "id" ) ); if ( CollectionUtils.isNotEmpty( middleIds ) ) { AssertUtils.isTrue( ! rolePermissionResourceService.removeByIds( middleIds.parallelStream() .map( Object::toString ) .collect( Collectors.toList() ) ) , "资源删除失败" ); } return true; }
Example 6
Source File: ClusterServiceImplTest.java From zkdoctor with Apache License 2.0 | 5 votes |
@Test public void testGetClusterIdsByUserId() throws Exception { List<ClusterAlarmUser> clusterAlarmUserList = clusterService.getClusterIdsByUserId(1); if (CollectionUtils.isNotEmpty(clusterAlarmUserList)) { for (ClusterAlarmUser clusterAlarmUser : clusterAlarmUserList) { System.out.println(clusterAlarmUser); } } else { System.out.println("Result is empty."); } }
Example 7
Source File: IndexSearchServiceImpl.java From herd with Apache License 2.0 | 5 votes |
@Override public IndexSearchResponse indexSearch(final IndexSearchRequest request, final Set<String> fields, final Set<String> match) { // Validate the search response fields validateSearchResponseFields(fields); // Validate the search response match validateSearchMatchFields(match); // Validate the search request validateIndexSearchRequest(request); Set<String> facetFields = new HashSet<>(); if (CollectionUtils.isNotEmpty(request.getFacetFields())) { facetFields.addAll(validateFacetFields(new HashSet<>(request.getFacetFields()))); //set the facets fields after validation request.setFacetFields(new ArrayList<>(facetFields)); } // Fetch the current active indexes String bdefActiveIndex = searchIndexDaoHelper.getActiveSearchIndex(SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name()); String tagActiveIndex = searchIndexDaoHelper.getActiveSearchIndex(SearchIndexTypeEntity.SearchIndexTypes.TAG.name()); return indexSearchDao.indexSearch(request, fields, match, bdefActiveIndex, tagActiveIndex); }
Example 8
Source File: ClusterStateServiceImplTest.java From zkdoctor with Apache License 2.0 | 5 votes |
@Test public void testGetClusterStateLogByClusterId() throws Exception { List<ClusterState> clusterStateList = clusterStateService.getClusterStateLogByClusterId(1, new Date(System.currentTimeMillis() - 60 * 60 * 1000), new Date()); if (CollectionUtils.isNotEmpty(clusterStateList)) { for (ClusterState clusterState : clusterStateList) { System.out.println(clusterState); } } else { System.out.println("Result is empty."); } }
Example 9
Source File: CassandraDACImpl.java From sunbird-lms-service with MIT License | 5 votes |
public void applyOperationOnRecordsAsync( String keySpace, String table, Map<String, Object> filters, List<String> fields, FutureCallback<ResultSet> callback) { Session session = connectionManager.getSession(keySpace); try { Select select; if (CollectionUtils.isNotEmpty(fields)) { select = QueryBuilder.select((String[]) fields.toArray()).from(keySpace, table); } else { select = QueryBuilder.select().all().from(keySpace, table); } if (MapUtils.isNotEmpty(filters)) { Select.Where where = select.where(); for (Map.Entry<String, Object> filter : filters.entrySet()) { Object value = filter.getValue(); if (value instanceof List) { where = where.and(QueryBuilder.in(filter.getKey(), ((List) filter.getValue()))); } else { where = where.and(QueryBuilder.eq(filter.getKey(), filter.getValue())); } } } ResultSetFuture future = session.executeAsync(select); Futures.addCallback(future, callback, Executors.newFixedThreadPool(1)); } catch (Exception e) { ProjectLogger.log(Constants.EXCEPTION_MSG_FETCH + table + " : " + e.getMessage(), e); throw new ProjectCommonException( ResponseCode.SERVER_ERROR.getErrorCode(), ResponseCode.SERVER_ERROR.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode()); } }
Example 10
Source File: InstanceServiceImplTest.java From zkdoctor with Apache License 2.0 | 5 votes |
@Test public void testGetInstancesByClusterId() throws Exception { List<InstanceInfo> instanceInfoList = instanceService.getInstancesByClusterId(1); if (CollectionUtils.isNotEmpty(instanceInfoList)) { for (InstanceInfo instanceInfo : instanceInfoList) { System.out.println(instanceInfo); } } else { System.out.println("Result is empty."); } }
Example 11
Source File: CompositeServerContext.java From pampas with Apache License 2.0 | 5 votes |
/** * 合并多个ServerContext的服务列表 */ private void merge() { try { if (merging.compareAndSet(false, true)) { for (ServerContext serverContext : serverContextList) { if (serverContext.lastRefreshedTime() <= 0) { //未刷新的ServerContext,强制刷新 serverContext.refreshServerList(); } String contextHash = serverContext.toString(); Long lastRefreshTime = ObjectUtils.defaultIfNull(this.refreshMap.get(contextHash), 0L); // 刷新时间不同,说明serverContext已经刷新 if (lastRefreshTime == null || lastRefreshTime <= 0 || lastRefreshTime.longValue() != serverContext.lastRefreshedTime()) { for (String serviceName : serverContext.getAllServiceName()) { if (instanceMap.contains(serviceName) && CollectionUtils.isNotEmpty(instanceMap.get(serviceName))) { instanceMap.get(serviceName).removeAll(serverContext.getServerList(serviceName)); instanceMap.get(serviceName).addAll(serverContext.getServerList(serviceName)); } else { instanceMap.put(serviceName, serverContext.getServerList(serviceName)); } } this.refreshMap.put(contextHash, serverContext.lastRefreshedTime()); this.lastRefreshedTime = System.currentTimeMillis(); } } } } catch (Exception ex) { log.error("合并CompositeServerContext服务列表失败", ex); } finally { merging.set(false); } }
Example 12
Source File: SubjectService.java From spring-microservice-exam with MIT License | 5 votes |
/** * 查询具体类型的题目列表 * * @param subjectDto subjectDto * @return SubjectDto * @author tangyi * @date 2019/06/17 17:12 */ public List<SubjectDto> findListByType(SubjectDto subjectDto) { List<SubjectDto> subjectDtos = subjectService(subjectDto.getType()).findSubjectList(subjectDto); // 选择题则查找具体的选项 if (SubjectTypeEnum.CHOICES.getValue().equals(subjectDto.getType()) && CollectionUtils.isNotEmpty(subjectDtos)) { // 查找选项信息 subjectDtos = subjectDtos.stream() .map(dto -> SubjectUtil.subjectChoicesToDto(subjectChoicesService.get(dto.getId()), true)) .collect(Collectors.toList()); } return subjectDtos; }
Example 13
Source File: ClusterServiceImplTest.java From zkdoctor with Apache License 2.0 | 5 votes |
@Test public void testClusterAlarmUsers() throws Exception { List<User> userList = clusterService.clusterAlarmUsers(1); if (CollectionUtils.isNotEmpty(userList)) { for (User user : userList) { System.out.println(user); } } else { System.out.println("Result is empty."); } }
Example 14
Source File: ClusterServiceImplTest.java From zkdoctor with Apache License 2.0 | 5 votes |
@Test public void testGetAllMonitoringClusterInfos() throws Exception { List<ClusterInfo> clusterInfoList = clusterService.getAllMonitoringClusterInfos(); if (CollectionUtils.isNotEmpty(clusterInfoList)) { for (ClusterInfo clusterInfo : clusterInfoList) { System.out.println(clusterInfo); } } else { System.out.println("Result is empty."); } }
Example 15
Source File: PlaylistServiceImpl.java From JuniperBot with GNU General Public License v3.0 | 5 votes |
private Playlist validateItems(Playlist playlist) { if (playlist != null && CollectionUtils.isNotEmpty(playlist.getItems()) && playlist.getItems().contains(null)) { playlist.setItems(playlist.getItems().stream().filter(Objects::nonNull).collect(Collectors.toList())); playlistRepository.save(playlist); } return playlist; }
Example 16
Source File: AssessmentBaseData.java From sakai with Educational Community License v2.0 | 5 votes |
public HashMap getAssessmentMetaDataMap(Set assessmentMetaDataSet) { HashMap assessmentMetaDataMap = new HashMap(); if (CollectionUtils.isNotEmpty(assessmentMetaDataSet)) { for (AssessmentMetaData assessmentMetaData : (Set<AssessmentMetaData>) assessmentMetaDataSet) { assessmentMetaDataMap.put(assessmentMetaData.getLabel(), assessmentMetaData.getEntry()); } } return assessmentMetaDataMap; }
Example 17
Source File: TaskFlowController.java From liteflow with Apache License 2.0 | 4 votes |
/** * 获取任务流列表 * * @param nameLike 名称模糊查询 * @param status 状态 * @param pageNum 页码 * @param pageSize 每页数量 * @return */ @RequestMapping(value = "list") public String list( @RequestParam(value = "id", required = false) Long id, @RequestParam(value = "nameLike", required = false) String nameLike, @RequestParam(value = "status", required = false) Integer status, @RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize ) { int total = 0; JSONArray datas = new JSONArray(); SessionUser user = getUser(); List<Long> flowIds = null; if (!user.getIsSuper()) { /**如果不是超级管理员,则只能查看自己权限范围内的*/ flowIds = userGroupAuthMidService.getTargetId(user.getId(), user.getGroupIds(), TargetTypeEnum.TARGET_TYPE_FLOW.getCode()); if (CollectionUtils.isEmpty(flowIds)) { return ResponseUtils.list(total, datas); } } FlowQM flowQM = new FlowQM(); flowQM.setIds(flowIds); flowQM.setId(id); flowQM.setNameLike(nameLike); flowQM.setStatus(status); flowQM.setPage(pageNum, pageSize); flowQM.addOrderDesc(TaskInstanceDependencyQM.COL_ID); List<Flow> flowList = flowService.list(flowQM); if (CollectionUtils.isNotEmpty(flowList)) { List<Long> userIds = flowList .stream() .map(Flow::getUserId) .distinct() .collect(Collectors.toList()); Map<Long, String> userIdAndName = getUserName(userIds); total = flowService.count(flowQM); flowList.forEach(flow -> { JSONObject obj = ModelUtils.getFlowObj(flow); setUserInfo(obj, flow.getUserId(), userIdAndName); datas.add(obj); }); } return ResponseUtils.list(total, datas); }
Example 18
Source File: TaskController.java From liteflow with Apache License 2.0 | 4 votes |
/** * 添加任务 * * @param name 名称 * @param cronExpression 调度表达式 * @param period 调度周期 * @param version 版本 * @param isConcurrency 是否可以并发 * @param executeStrategy 执行策略 * @param pluginId 插件id * @param pluginConf 插件配置 * @param isRetry 是否重试 * @param retryConf 重试策略 * @param description 说明 * @return */ @RequestMapping(value = "add") public String add( @RequestParam(value = "name") String name, @RequestParam(value = "cronExpression") String cronExpression, @RequestParam(value = "period") Integer period, @RequestParam(value = "version", required = false, defaultValue = "1") Integer version, @RequestParam(value = "concurrency", required = false, defaultValue = "0") Integer isConcurrency, @RequestParam(value = "concurrentStrategy", required = false, defaultValue = "1") Integer executeStrategy, @RequestParam(value = "pluginId") Long pluginId, @RequestParam(value = "pluginConf", required = false) String pluginConf, @RequestParam(value = "isRetry") Integer isRetry, @RequestParam(value = "retryConf", required = false, defaultValue = "") String retryConf, @RequestParam(value = "maxRunTime") Integer maxRunTime, @RequestParam(value = "alarmEmail", required = false) String alarmEmail, @RequestParam(value = "alarmPhone", required = false) String alarmPhone, @RequestParam(value = "description", required = false, defaultValue = "") String description ) { TaskQM taskQM = new TaskQM(); taskQM.setName(name); List<Task> taskList = taskService.list(taskQM); if (CollectionUtils.isNotEmpty(taskList)) { return ResponseUtils.error("该名称已经存在"); } String cron = QuartzUtils.completeCrontab(cronExpression); boolean crontabValid = QuartzUtils.isCrontabValid(cron); if (!crontabValid) { throw new ConsoleRuntimeException("请确认cron表达式的合法性"); } Task task = new Task(); task.setName(name); task.setCronExpression(cronExpression); task.setPeriod(period); task.setVersion(version); task.setIsConcurrency(isConcurrency); task.setExecuteStrategy(executeStrategy); task.setPluginId(pluginId); task.setPluginConf(pluginConf); task.setIsRetry(isRetry); task.setRetryConf(retryConf); task.setDescription(description); task.setMaxRunTime(maxRunTime); task.setAlarmEmail(alarmEmail); task.setAlarmPhone(alarmPhone); task.setUserId(getUser().getId()); taskService.add(task); return ResponseUtils.success("添加任务成功"); }
Example 19
Source File: VkSubscriptionServiceImpl.java From JuniperBot with GNU General Public License v3.0 | 4 votes |
@Override protected WebhookMessage createMessage(CallbackMessage<Wallpost> message, VkConnection connection) { Wallpost post = message.getObject(); if (PostType.SUGGEST.equals(post.getPostType())) { return null; // do not post suggestions } if (connection.isGroupOnlyPosts() && !Objects.equals(connection.getGroupId(), post.getFromId() * -1)) { return null; } List<WallpostAttachment> attachments = new ArrayList<>(CollectionUtils.isNotEmpty(post.getAttachments()) ? post.getAttachments() : Collections.emptyList()); attachments.sort((a, b) -> { Integer aP = ATTACHMENT_PRIORITY.get(a.getType()); Integer bP = ATTACHMENT_PRIORITY.get(b.getType()); return bP.compareTo(aP); }); List<WebhookEmbedBuilder> processEmbeds = new ArrayList<>(); Set<String> images = new HashSet<>(); attachments.forEach(e -> processAttachment(images, connection, processEmbeds, message, e)); List<WebhookEmbedBuilder> embeds = processEmbeds.size() > 10 ? processEmbeds.subList(0, 10) : processEmbeds; String content = trimTo(CommonUtils.parseVkLinks(HtmlUtils.htmlUnescape(post.getText())), 2000); WebhookEmbedBuilder contentEmbed = null; if (embeds.size() == 1) { contentEmbed = embeds.get(0); } else if (embeds.isEmpty() && StringUtils.isNotEmpty(content)) { contentEmbed = createBuilder(); embeds.add(contentEmbed); } if (contentEmbed != null) { if (connection.isShowDate() && post.getDate() != null) { contentEmbed.setTimestamp(new Date(((long) post.getDate()) * 1000).toInstant()); } String url = String.format(WALL_URL, message.getGroupId(), post.getId()); setText(connection, contentEmbed, post.getText(), url); content = null; // show it on embed instead } if (connection.isMentionEveryone()) { content = CommonUtils.trimTo(content != null ? CommonUtils.EVERYONE + content : CommonUtils.EVERYONE, 2000); } WebhookMessageBuilder builder = new WebhookMessageBuilder().setContent(content); if (!embeds.isEmpty()) { builder.addEmbeds(embeds.stream().map(WebhookEmbedBuilder::build).collect(Collectors.toList())); } return !builder.isEmpty() ? builder.build() : null; }
Example 20
Source File: PreBidRequestContextFactory.java From prebid-server-java with Apache License 2.0 | 4 votes |
private static boolean isValidAdUnit(AdUnit adUnit) { return Objects.nonNull(adUnit.getCode()) && CollectionUtils.isNotEmpty(adUnit.getSizes()); }