List of usage examples for org.apache.commons.collections4 CollectionUtils isNotEmpty
public static boolean isNotEmpty(final Collection<?> coll)
From source file:com.baifendian.swordfish.execserver.job.storm.StormSubmitArgsUtil.java
private static List<String> jarArgs(StormJarParam stormJarParam) { List<String> args = new ArrayList<>(); args.add(JAR);/*from w ww . j a v a 2 s .c o m*/ //add mainJar args.add(stormJarParam.getMainJar().getRes()); //add mainClass args.add(stormJarParam.getMainClass()); //add Jars List<ResourceInfo> jars = stormJarParam.getJars(); if (CollectionUtils.isNotEmpty(jars)) { args.add(JARS); args.add(StringUtils.join(jars.stream().map(p -> p.getRes()).toArray(), ",")); } if (StringUtils.isNotEmpty(stormJarParam.getArgs())) { args.add(stormJarParam.getArgs()); } if (StringUtils.isNotEmpty(stormJarParam.getArtifacts())) { args.add(ARTIFACTS); args.add(stormJarParam.getArtifacts()); } if (StringUtils.isNotEmpty(stormJarParam.getArtifactRepositories())) { args.add(ARTIFACTREPOSITORIES); args.add(stormJarParam.getArtifactRepositories()); } return args; }
From source file:com.mpush.cache.redis.manager.ZKRedisClusterManager.java
/** * zk ??/* www. j a v a 2s .com*/ */ @Override public void init() { Logs.Console.info("begin init redis cluster"); if (!ZKClient.I.isRunning()) throw new RedisException("init redis cluster ex, ZK client not running."); if (CollectionUtils.isNotEmpty(CC.mp.redis.nodes)) { register(CC.mp.redis.nodes); } watcher.watch(); Collection<ZKRedisNode> nodes = watcher.getCache().values(); if (CollectionUtils.isEmpty(nodes)) { Logs.REDIS.error("init redis client error, redis server is none."); throw new RedisException("init redis client error, redis server is none."); } if (nodes.isEmpty()) throw new RedisException("init redis sever fail groupList is null"); Logs.Console.info("init redis cluster success..."); }
From source file:com.goodhuddle.huddle.repository.MemberSpecification.java
public static Specification<Member> search(final Huddle huddle, final SearchMembersRequest request) { return new Specification<Member>() { @Override/*from ww w.ja v a2s .co m*/ public Predicate toPredicate(Root<Member> member, CriteriaQuery<?> query, CriteriaBuilder builder) { Predicate conjunction = builder.conjunction(); // huddle conjunction.getExpressions().add(builder.equal(member.get("huddle"), huddle)); // keywords if (StringUtils.isNotBlank(request.getKeywords())) { String[] terms = StringUtils.split(request.getKeywords()); for (String keyword : terms) { if (keyword != null && keyword.length() > 0) { String matchTerm = "%" + keyword.toLowerCase() + "%"; conjunction.getExpressions().add(builder.or( builder.like(builder.lower(member.<String>get("username")), matchTerm), builder.like(builder.lower(member.<String>get("email")), matchTerm), builder.like(builder.lower(member.<String>get("firstName")), matchTerm), builder.like(builder.lower(member.<String>get("lastName")), matchTerm))); } } } // security groups if (CollectionUtils.isNotEmpty(request.getSecurityGroupIds())) { Join<Object, Object> securityGroup = member.join("securityGroup", request.isIncludeNoAccess() ? JoinType.LEFT : JoinType.INNER); Predicate disjunction = builder.disjunction(); for (Long id : request.getSecurityGroupIds()) { disjunction.getExpressions().add(builder.equal(securityGroup.get("id"), id)); } if (request.isIncludeNoAccess()) { disjunction.getExpressions().add(builder.isNull(securityGroup.get("id"))); } conjunction.getExpressions().add(disjunction); } else if (request.isIncludeNoAccess()) { conjunction.getExpressions().add(builder.isNull(member.get("securityGroup"))); } // tags MemberTagFilter tagFilter = request.getTags(); if (tagFilter != null) { if (tagFilter.getIncluded() != null) { if (CollectionUtils.isNotEmpty(tagFilter.getIncluded().getTagIds())) { MemberTagFilter.TagSet included = request.getTags().getIncluded(); MatchType matchType = included.getMatchType(); Predicate tagPredicate = matchType.equals(MatchType.all) ? builder.conjunction() : builder.disjunction(); for (Long tagId : included.getTagIds()) { Subquery<Member> sq = query.subquery(Member.class); Root<Member> subMember = sq.from(Member.class); Join<Member, Tag> tag = subMember.join("tags"); sq.select(subMember).where(builder.equal(tag.get("id"), tagId)); tagPredicate.getExpressions().add(builder.in(member).value(sq)); } conjunction.getExpressions().add(tagPredicate); } } if (tagFilter.getExcluded() != null) { if (CollectionUtils.isNotEmpty(tagFilter.getExcluded().getTagIds())) { MemberTagFilter.TagSet excluded = request.getTags().getExcluded(); MatchType matchType = excluded.getMatchType(); Predicate tagPredicate = matchType.equals(MatchType.all) ? builder.disjunction() : builder.conjunction(); for (Long tagId : excluded.getTagIds()) { Subquery<Member> sq = query.subquery(Member.class); Root<Member> subMember = sq.from(Member.class); Join<Member, Tag> tag = subMember.join("tags"); sq.select(subMember).where(builder.equal(tag.get("id"), tagId)); tagPredicate.getExpressions().add(builder.in(member).value(sq).not()); } conjunction.getExpressions().add(tagPredicate); } } } return conjunction; } }; }
From source file:com.fredhopper.core.connector.index.generate.engine.ProductExporter.java
@Override protected List<Violation> exportItem(final AbstractCsvWriter<FhProductData> writer, final FhProductData item, final IndexingContext context) throws IOException { final List<Violation> itemErrors = super.exportItem(writer, item, context); if (itemErrors.isEmpty()) { if (CollectionUtils.isNotEmpty(item.getAttributes())) { attributeExporter.process(item.getAttributes(), context); }//from w w w. j a v a 2s . c o m if (CollectionUtils.isNotEmpty(item.getVariants())) { variantExporter.process(item.getVariants(), context); } } return itemErrors; }
From source file:io.github.swagger2markup.internal.utils.PropertyUtils.java
/** * Retrieves the type and format of a property. * * @param property the property/*from w ww . j av a 2 s .c o m*/ * @param definitionDocumentResolver the definition document resolver * @return the type of the property */ public static Type getType(Property property, Function<String, String> definitionDocumentResolver) { Validate.notNull(property, "property must not be null"); Type type; if (property instanceof RefProperty) { RefProperty refProperty = (RefProperty) property; if (refProperty.getRefFormat() == RefFormat.RELATIVE) type = new ObjectType(refProperty.getTitle(), null); // FIXME : Workaround for https://github.com/swagger-api/swagger-parser/issues/177 else type = new RefType(definitionDocumentResolver.apply(refProperty.getSimpleRef()), new ObjectType(refProperty.getSimpleRef(), null /* FIXME, not used for now */)); } else if (property instanceof ArrayProperty) { ArrayProperty arrayProperty = (ArrayProperty) property; Property items = arrayProperty.getItems(); type = new ArrayType(arrayProperty.getTitle(), getType(items, definitionDocumentResolver)); } else if (property instanceof MapProperty) { MapProperty mapProperty = (MapProperty) property; Property additionalProperties = mapProperty.getAdditionalProperties(); type = new MapType(mapProperty.getTitle(), getType(additionalProperties, definitionDocumentResolver)); } else if (property instanceof StringProperty) { StringProperty stringProperty = (StringProperty) property; List<String> enums = stringProperty.getEnum(); if (CollectionUtils.isNotEmpty(enums)) { type = new EnumType(stringProperty.getTitle(), enums); } else { type = new BasicType(stringProperty.getType(), stringProperty.getTitle()); } } else if (property instanceof ObjectProperty) { type = new ObjectType(property.getTitle(), ((ObjectProperty) property).getProperties()); } else { if (isNotBlank(property.getFormat())) { type = new BasicType(property.getType(), property.getTitle(), property.getFormat()); } else { type = new BasicType(property.getType(), property.getTitle()); } } return type; }
From source file:com.casker.portfolio.controller.PortfolioAdminController.java
/** * ?? //from ww w . j a v a2 s . c o m * * @param model * @param search * @param page * @return */ @RequestMapping("/portfolio") public String getPortfolioList(Model model, PortfolioSearch search, @ModelAttribute Page page) { int totalCount = portfolioService.getPortfolioListCount(search); List<Portfolio> portfolioList = portfolioService.getPortfolioList(search); if (CollectionUtils.isNotEmpty(portfolioList)) { page.setTotalCount(totalCount); } PageUtil.setPage(page); model.addAttribute("portfolioList", portfolioList); return VIEW_PREFIX + "sub/portfolio_list :: portfolioList"; }
From source file:io.cloudslang.lang.systemtests.RunDataAggregatorListener.java
private StepData buildStepData(List<LanguageEventData> data) { List<LanguageEventData> stepEvents = selectByStepType(data, LanguageEventData.StepType.STEP); List<LanguageEventData> executableEvents = selectByStepType(data, LanguageEventData.StepType.getExecutableTypes()); LanguageEventData inputsEvent;/* w w w .jav a 2 s .c o m*/ LanguageEventData outputsEvent; boolean isStep = CollectionUtils.isNotEmpty(stepEvents); if (isStep) { inputsEvent = selectByEventType(stepEvents, ScoreLangConstants.EVENT_ARGUMENT_END); outputsEvent = selectByEventType(stepEvents, ScoreLangConstants.EVENT_OUTPUT_END); } else { inputsEvent = selectByEventType(executableEvents, ScoreLangConstants.EVENT_INPUT_END); outputsEvent = selectByEventType(executableEvents, ScoreLangConstants.EVENT_OUTPUT_END); } String path = inputsEvent.getPath(); String stepName = inputsEvent.getStepName(); Map<String, Serializable> inputs; if (isStep) { inputs = inputsEvent.getArguments(); } else { inputs = inputsEvent.getInputs(); } Map<String, Serializable> outputs = outputsEvent == null ? null : outputsEvent.getOutputs(); String result = outputsEvent == null ? null : (String) outputsEvent.get(LanguageEventData.RESULT); String executableName = executableEvents.get(0).getStepName(); return new StepData(path, stepName, inputs, outputs, executableName, result); }
From source file:com.casker.portfolio.controller.RecentlyAdminController.java
/** * // w w w .ja va2 s . c o m * * @param model * @param search * @param page * @return */ @RequestMapping("/recently") public String getRecentlyList(Model model, RecentlySearch search, @ModelAttribute Page page) { int totalCount = portfolioService.getRecentlyListCount(search); List<Recently> recentlyList = portfolioService.getRecentlyList(search); if (CollectionUtils.isNotEmpty(recentlyList)) { page.setTotalCount(totalCount); } PageUtil.setPage(page); model.addAttribute("recentlyList", recentlyList); return VIEW_PREFIX + "sub/recently_list :: recentlyList"; }
From source file:com.jkoolcloud.tnt4j.streams.filters.StreamFiltersGroup.java
@Override public boolean doFilter(T value) throws FilterException { if (CollectionUtils.isNotEmpty(activityFilters)) { for (StreamEntityFilter<T> aFilter : activityFilters) { if (aFilter.doFilter(value)) { return true; }/*from www .j a va 2 s .c om*/ } } return false; }
From source file:com.jkoolcloud.tnt4j.streams.filters.GroovyActivityExpressionFilter.java
@Override public boolean doFilter(ActivityInfo activityInfo) throws FilterException { Binding binding = new Binding(); if (CollectionUtils.isNotEmpty(exprVars)) { Object fValue;//from ww w .j av a2 s . c o m String fieldName; for (String eVar : exprVars) { fieldName = eVar.substring(2, eVar.length() - 1); fValue = activityInfo.getFieldValue(fieldName); fieldName = placeHoldersMap.get(eVar); binding.setVariable(StringUtils.isEmpty(fieldName) ? eVar : fieldName, fValue); } } GroovyShell shell = new GroovyShell(binding, StreamsScriptingUtils.getDefaultGroovyCompilerConfig()); try { boolean match = (boolean) shell.evaluate(getExpression()); boolean filteredOut = isFilteredOut(getHandleType(), match); activityInfo.setFiltered(filteredOut); return filteredOut; } catch (Exception exc) { throw new FilterException(StreamsResources.getStringFormatted(StreamsResources.RESOURCE_BUNDLE_NAME, "ExpressionFilter.filtering.failed", filterExpression), exc); } }