List of usage examples for org.apache.commons.collections4 CollectionUtils isEmpty
public static boolean isEmpty(final Collection<?> coll)
From source file:com.mirth.connect.server.api.servlets.AlertServlet.java
@Override public List<AlertModel> getAlerts(Set<String> alertIds) { try {//from w w w. ja va 2s . com if (CollectionUtils.isEmpty(alertIds)) { return alertController.getAlerts(); } List<AlertModel> alerts = new ArrayList<AlertModel>(); for (AlertModel alert : alertController.getAlerts()) { if (alertIds.contains(alert.getId())) { alerts.add(alert); } } return alerts; } catch (ControllerException e) { throw new MirthApiException(e); } }
From source file:io.cloudslang.lang.runtime.bindings.ParallelLoopBinding.java
public List<Value> bindParallelLoopList(LoopStatement parallelLoopStatement, Context flowContext, Set<SystemProperty> systemProperties, String nodeName) { Validate.notNull(parallelLoopStatement, "parallel loop statement cannot be null"); Validate.notNull(flowContext, "flow context cannot be null"); Validate.notNull(systemProperties, "system properties cannot be null"); Validate.notNull(nodeName, "node name cannot be null"); List<Value> result;// w w w .j ava 2 s.c o m try { Value evalResult = scriptEvaluator.evalExpr(parallelLoopStatement.getExpression(), flowContext.getImmutableViewOfVariables(), systemProperties, parallelLoopStatement.getFunctionDependencies()); evalResult = getEvalResultForMap(evalResult, parallelLoopStatement, parallelLoopStatement.getExpression()); result = (List<Value>) getIterableFromEvalResult(evalResult); } catch (Throwable t) { throw new RuntimeException(generateParallelLoopExpressionMessage(nodeName, t.getMessage()), t); } if (CollectionUtils.isEmpty(result)) { throw new RuntimeException(generateParallelLoopExpressionMessage(nodeName, "expression is empty")); } return result; }
From source file:net.ontopia.topicmaps.rest.v1.TMObjectController.java
public TMObjectIF resolve(TopicMapIF tm, String objectId, Collection<URILocator> itemIdentifiers) { if (objectId != null) { return tm.getObjectById(objectId); }/* w w w.jav a 2 s. c o m*/ if (!CollectionUtils.isEmpty(itemIdentifiers)) { for (URILocator ii : itemIdentifiers) { TMObjectIF objectByItemIdentifier = tm.getObjectByItemIdentifier(ii); if (objectByItemIdentifier != null) { return objectByItemIdentifier; } } } return null; }
From source file:net.birelian.xmltoyaml.Main.java
/** * Execute application/*from www . j a v a 2s. c o m*/ * * @throws ApplicationException If any */ private void execute() throws ApplicationException { // Check that output directory exists. Create if it doesn't. checkOutputDirectory(); // First try to read files from the SOURCE dir in the classpath List<String> files = getFileListFromClasspath(); // If files is empty try to get them from SOURCE dir in the file system if (CollectionUtils.isEmpty(files)) { files = getFilesFromFileSystem(); } // Convert files for (String file : files) { processFile(file); } }
From source file:com.hp.autonomy.frontend.find.core.savedsearches.FieldTextParserImpl.java
private FieldText rangesToFieldText(final Collection<ParametricRange> parametricRanges) { if (CollectionUtils.isEmpty(parametricRanges)) { return null; } else {/*w w w . j a v a2 s . c o m*/ final Iterator<ParametricRange> iterator = parametricRanges.iterator(); FieldText fieldText = rangeToFieldText(iterator.next()); while (iterator.hasNext()) { fieldText = fieldText.AND(rangeToFieldText(iterator.next())); } return fieldText; } }
From source file:com.jkoolcloud.tnt4j.streams.scenario.WsScenarioStep.java
/** * Checks if scenario step has no requests defined. * * @return flag indicating scenario has no requests defined *//*w ww . j av a 2 s. c o m*/ public boolean isEmpty() { return CollectionUtils.isEmpty(requests); }
From source file:cop.raml.utils.javadoc.MethodJavaDoc.java
@NotNull private static TagReturn getReturn(List<String> doc) { if (CollectionUtils.isEmpty(doc)) return TagReturn.NULL; Matcher matcher;//from www.ja v a 2s . c o m StringBuilder buf = null; for (String line : doc) { line = line.trim(); if ((matcher = JavaDocTag.RETURN.getPattern().matcher(line)).find()) buf = new StringBuilder(StringUtils.defaultString(matcher.group("text"), "")); else if (buf != null) { if (TAG.matcher(line).find()) return createTagReturn(buf.toString()); buf.append(buf.length() > 0 ? '\n' : "").append(line); } } return createTagReturn(buf != null ? buf.toString() : null); }
From source file:com.mirth.connect.server.api.servlets.ChannelServlet.java
@Override @DontCheckAuthorized/*from w w w . ja v a 2 s.c o m*/ public List<Channel> getChannels(Set<String> channelIds, boolean pollingOnly) { if (CollectionUtils.isNotEmpty(channelIds)) { parameterMap.put("channelIds", channelIds); } if (!isUserAuthorized()) { return new ArrayList<Channel>(); } List<Channel> channels; if (CollectionUtils.isEmpty(channelIds)) { channels = redactChannels(channelController.getChannels(null)); } else { channels = channelController.getChannels(redactChannelIds(channelIds)); } if (pollingOnly) { retainPollingChannels(channels); } return channels; }
From source file:com.jkoolcloud.tnt4j.streams.transform.FuncGetObjectName.java
/** * Resolves desired object name from provided fully qualified object name. Fully qualified object name can be * provided as {@link String}, {@link org.w3c.dom.Node} or {@link org.w3c.dom.NodeList} (first node item containing * object name)./* w w w . j a v a 2 s. co m*/ * <p> * function arguments sequence: * <ul> * <li>1 - fully qualified object name. Required.</li> * <li>2 - resolution options: DEFAULT, BEFORE, AFTER, REPLACE, SECTION, FULL. Optional.</li> * <li>3 - search symbols. Optional.</li> * <li>4 - replacement symbols. Optional</li> * </ul> * * @param args * function arguments list * @return object name resolved form provided fully qualified object name * * @see org.w3c.dom.Node * @see org.w3c.dom.NodeList */ @Override @SuppressWarnings("rawtypes") public Object evaluate(List args) { Object param = CollectionUtils.isEmpty(args) ? null : args.get(0); if (param == null) { return param; } String objectFQN = null; if (param instanceof String) { objectFQN = (String) param; } else if (param instanceof Node) { objectFQN = ((Node) param).getTextContent(); } else if (param instanceof NodeList) { NodeList nodes = (NodeList) param; if (nodes.getLength() > 0) { Node node = nodes.item(0); objectFQN = node.getTextContent(); } } if (StringUtils.isEmpty(objectFQN)) { return objectFQN; } return resolveObjectName(objectFQN, args); }
From source file:io.kodokojo.service.SmtpEmailSender.java
@Override public void send(List<String> to, List<String> cc, List<String> ci, String subject, String content, boolean htmlContent) { if (CollectionUtils.isEmpty(to)) { throw new IllegalArgumentException("to must be defined."); }// www. j a va2 s . c om if (isBlank(content)) { throw new IllegalArgumentException("content must be defined."); } Session session = Session.getDefaultInstance(properties, new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); Message message = new MimeMessage(session); try { message.setFrom(from); message.setSubject(subject); InternetAddress[] toInternetAddress = convertToInternetAddress(to); message.setRecipients(Message.RecipientType.TO, toInternetAddress); if (CollectionUtils.isNotEmpty(cc)) { InternetAddress[] ccInternetAddress = convertToInternetAddress(cc); message.setRecipients(Message.RecipientType.CC, ccInternetAddress); } if (CollectionUtils.isNotEmpty(ci)) { InternetAddress[] ciInternetAddress = convertToInternetAddress(ci); message.setRecipients(Message.RecipientType.BCC, ciInternetAddress); } if (htmlContent) { message.setContent(content, "text/html"); } else { message.setText(content); } message.setHeader("X-Mailer", "Kodo Kojo mailer"); message.setSentDate(new Date()); Transport.send(message); } catch (MessagingException e) { LOGGER.error("Unable to send email to {} with subject '{}'", StringUtils.join(to, ","), subject, e); } }