List of usage examples for org.apache.commons.collections4 CollectionUtils isEmpty
public static boolean isEmpty(final Collection<?> coll)
From source file:badminton.common.Util.CollectionUtil.java
/** * ??//from w ww. j a v a2 s. c o m * * @param collection * @return true:?,false:?? */ public static boolean isEmpty(final Collection<?> collection) { return CollectionUtils.isEmpty(collection); }
From source file:cop.raml.utils.javadoc.JavaDocUtils.java
public static String getText(List<String> lines) { if (CollectionUtils.isEmpty(lines)) return null; StringBuilder buf = new StringBuilder(); int emptyLines = 0; for (String line : lines) { if (StringUtils.isBlank(line)) { if (buf.length() > 0) emptyLines++;//ww w .jav a2 s . c om } else if (JavaDocTag.startsWith(line)) break; else buf.append(StringUtils.repeat("\n", emptyLines + (buf.length() > 0 ? 1 : 0))).append(line); } return clearMacros(buf.toString()); }
From source file:com.chadekin.jadys.commons.expression.SqlExpressionBuilder.java
public static boolean isBlankValue(Object value) { boolean isBlank = value == null || StringUtils.isBlank(value.toString()); if (!isBlank) { boolean isEmptyCollection = value instanceof Collection && CollectionUtils.isEmpty((Collection) value); boolean isEmptyArray = value.getClass().isArray() && Array.getLength(value) == 0; isBlank = isEmptyCollection || isEmptyArray; }//from w ww .j a v a2 s.c om return isBlank; }
From source file:com.adguard.commons.collections.Lists.java
/** * Safe method to remove an element from collection. * If either collection is empty or element is null - returns false. * * @param collection Collection/* w w w . j a v a 2 s .c o m*/ * @param element Element * @param <T> Any type * @return true if element has been removed */ public static <T> boolean remove(Collection<T> collection, T element) { if (element == null) { return false; } //noinspection SimplifiableIfStatement if (CollectionUtils.isEmpty(collection)) { return false; } return collection.remove(element); }
From source file:co.runrightfast.core.utils.JsonUtils.java
static javax.json.JsonArray toJsonArray(final List<String> stringList) { if (CollectionUtils.isEmpty(stringList)) { return EMPTY_ARRAY; }/*from ww w . ja va 2 s .c o m*/ final JsonArrayBuilder json = Json.createArrayBuilder(); stringList.forEach(json::add); return json.build(); }
From source file:com.ebay.myriad.scheduler.SchedulerUtils.java
public static boolean isUniqueHostname(Offer offer, Collection<NodeTask> tasks) { Preconditions.checkArgument(offer != null); String offerHostname = offer.getHostname(); if (CollectionUtils.isEmpty(tasks)) { return true; }// w ww . j a v a2s.co m boolean uniqueHostname = tasks.stream().filter(task -> offerHostname.equalsIgnoreCase(task.getHostname())) .count() == 0; LOGGER.info("Offer's hostname {} is unique: {}", offerHostname, uniqueHostname); return uniqueHostname; }
From source file:com.adguard.commons.collections.Lists.java
/** * Safe method to remove all specified elements * from the collection.//from w w w. ja v a 2s . c om * * @param collection Collection * @param elements Elements to remove * @param <T> Any type */ public static <T> void removeAll(Collection<T> collection, Collection<T> elements) { if (CollectionUtils.isEmpty(collection) || CollectionUtils.isEmpty(elements)) { return; } for (T element : elements) { collection.remove(element); } }
From source file:com.thoughtworks.go.apiv1.secretconfigs.representers.SecretConfigRepresenter.java
public static void toJSON(OutputWriter jsonWriter, SecretConfig secretConfig) { if (secretConfig == null) return;// w w w . ja va2 s .c o m jsonWriter .addLinks( linksWriter -> linksWriter.addLink("self", Routes.SecretConfigsAPI.id(secretConfig.getId())) .addAbsoluteLink("doc", Routes.SecretConfigsAPI.DOC) .addLink("find", Routes.SecretConfigsAPI.find())) .add("id", secretConfig.getId()).add("plugin_id", secretConfig.getPluginId()) .addIfNotNull("description", secretConfig.getDescription()); if (secretConfig.hasErrors()) { Map<String, String> fieldMapping = Collections.singletonMap("pluginId", "plugin_id"); jsonWriter.addChild("errors", errorWriter -> new ErrorGetter(fieldMapping).toJSON(errorWriter, secretConfig)); } jsonWriter.addChildList("properties", listWriter -> { ConfigurationPropertyRepresenter.toJSON(listWriter, secretConfig.getConfiguration()); }); if (!CollectionUtils.isEmpty(secretConfig.getRules())) { jsonWriter.addChildList("rules", rulesWriter -> RulesRepresenter.toJSON(rulesWriter, secretConfig.getRules())); } }
From source file:nc.noumea.mairie.appock.core.utility.MessageErreurUtilTest.java
@Test public void construitListeMessageErreurViolationContrainte() { Assert.assertTrue( CollectionUtils.isEmpty(MessageErreurUtil.construitListeMessageErreurViolationContrainte(null))); }
From source file:com.mirth.connect.server.api.servlets.ChannelGroupServlet.java
@Override public List<ChannelGroup> getChannelGroups(Set<String> channelGroupIds) { if (CollectionUtils.isEmpty(channelGroupIds)) { return channelController.getChannelGroups(null); } else {/*from w w w . j ava 2 s .c om*/ return channelController.getChannelGroups(channelGroupIds); } }