Tabnine Logo
ListUtils
Code IndexAdd Tabnine to your IDE (free)

How to use
ListUtils
in
org.apache.commons.collections4

Best Java code snippets using org.apache.commons.collections4.ListUtils (Showing top 20 results out of 567)

origin: BroadleafCommerce/BroadleafCommerce

  @SuppressWarnings("unchecked")
  protected List<SolrJSONFacet> resolveJSONFacetList(List<NamedList> listOfNamedList) {
    List<SolrJSONFacet> listOfJSONFacet = new ArrayList<>();
    for (NamedList namedList : ListUtils.emptyIfNull(listOfNamedList)) {
      listOfJSONFacet.add(resolveJSONFacet(namedList));
    }
    return listOfJSONFacet;
  }
}
origin: org.apache.commons/commons-collections4

/**
 * Returns the sum of the given lists.  This is their intersection
 * subtracted from their union.
 *
 * @param <E> the element type
 * @param list1  the first list
 * @param list2  the second list
 * @return  a new list containing the sum of those lists
 * @throws NullPointerException if either list is null
 */
public static <E> List<E> sum(final List<? extends E> list1, final List<? extends E> list2) {
  return subtract(union(list1, list2), intersection(list1, list2));
}
origin: org.apache.commons/commons-collections4

/**
 * {@inheritDoc}
 * <p>
 * NOTE: from 4.0, an unmodifiable list will be returned, as changes to the
 * subList can invalidate the parent list.
 */
@Override
public List<E> subList(final int fromIndex, final int toIndex) {
  final List<E> superSubList = super.subList(fromIndex, toIndex);
  final Set<E> subSet = createSetBasedOnList(set, superSubList);
  return ListUtils.unmodifiableList(new SetUniqueList<>(superSubList, subSet));
}
origin: jamesagnew/hapi-fhir

/**
 * Returns an ordered list of invokers for the given pointcut. Note that
 * a new and stable list is returned to.. do whatever you want with it.
 */
private List<BaseInvoker> getInvokersForPointcut(Pointcut thePointcut) {
  List<BaseInvoker> invokers;
  boolean haveAnonymousInvokers;
  synchronized (myRegistryMutex) {
    List<BaseInvoker> globalInvokers = myInvokers.get(thePointcut);
    List<BaseInvoker> anonymousInvokers = myAnonymousInvokers.get(thePointcut);
    invokers = ListUtils.union(anonymousInvokers, globalInvokers);
    haveAnonymousInvokers = anonymousInvokers.isEmpty() == false;
  }
  if (haveAnonymousInvokers) {
    invokers.sort(Comparator.naturalOrder());
  }
  return invokers;
}
origin: CloudSlang/cloud-slang

/**
 * @param activeSuites     the suite names that are active
 * @param parallelSuites   the suite names to be executed in parallel
 * @param sequentialSuites the suite names to be executed in sequential manner
 * @return
 */
private static List<String> getDefaultRunModeTestSuites(final List<String> activeSuites,
                            final List<String> parallelSuites,
                            final List<String> sequentialSuites) {
  return removeAll(new ArrayList<>(activeSuites), union(parallelSuites, sequentialSuites));
}
origin: jamesagnew/hapi-fhir

List<String> nextPermittedValues = ListUtils.intersection(nextRequestedValues, nextAllowedValues);
if (nextPermittedValues.size() > 0) {
  restrictedExistingList = true;
origin: org.apache.commons/commons-collections4

 /**
  * Removes the elements in <code>remove</code> from <code>collection</code>. That is, this
  * method returns a collection containing all the elements in <code>c</code>
  * that are not in <code>remove</code>. The cardinality of an element <code>e</code>
  * in the returned collection is the same as the cardinality of <code>e</code>
  * in <code>collection</code> unless <code>remove</code> contains <code>e</code>, in which
  * case the cardinality is zero. This method is useful if you do not wish to modify
  * the collection <code>c</code> and thus cannot call <code>collection.removeAll(remove);</code>.
  * <p>
  * This implementation iterates over <code>collection</code>, checking each element in
  * turn to see if it's contained in <code>remove</code>. If it's not contained, it's added
  * to the returned list. As a consequence, it is advised to use a collection type for
  * <code>remove</code> that provides a fast (e.g. O(1)) implementation of
  * {@link Collection#contains(Object)}.
  *
  * @param <E>  the type of object the {@link Collection} contains
  * @param collection  the collection from which items are removed (in the returned collection)
  * @param remove  the items to be removed from the returned <code>collection</code>
  * @return a <code>Collection</code> containing all the elements of <code>collection</code> except
  * any elements that also occur in <code>remove</code>.
  * @throws NullPointerException if either parameter is null
  * @since 4.0 (method existed in 3.2 but was completely broken)
  */
 public static <E> Collection<E> removeAll(final Collection<E> collection, final Collection<?> remove) {
   return ListUtils.removeAll(collection, remove);
}
origin: org.terrier/terrier-core

static <T> List<List<T>> splitList(final List<T> all, final int k) {
  assert all.size() > 0;
  int size = all.size()/k;
  if (all.size() % k != 0)
    size++;
  List<List<T>> rtr = ListUtils.partition(all, size);
  //we can have no more than k partitions
  assert rtr.size() <= k;
  return rtr;
}
origin: apache/metron

List<RiskLevelRule> allRules = ListUtils.union(triageConfig.getRiskLevelRules(), newRules);
triageConfig.setRiskLevelRules(allRules);
origin: CloudSlang/cloud-slang

private static void addErrorIfSameTestSuiteIsInBothParallelOrSequential(List<String> testSuitesParallel,
                                    List<String> testSuitesSequential) {
  final List<String> intersection = ListUtils.intersection(testSuitesParallel, testSuitesSequential);
  if (!intersection.isEmpty()) {
    final String message = String.format(MESSAGE_BOTH_PARALLEL_AND_SEQUENTIAL_EXECUTION,
        getListForPrint(intersection));
    log.error(message);
    throw new IllegalStateException();
  }
}
origin: gocd/gocd

private List<PartialConfig> removePartialsThatDoNotCorrespondToTheCurrentConfigReposList(List<PartialConfig> partList) {
  List<Object> notToBeMerged = new ArrayList<>();
  for (PartialConfig partialConfig : partList) {
    if (partialConfig.getOrigin() instanceof RepoConfigOrigin) {
      RepoConfigOrigin origin = (RepoConfigOrigin) partialConfig.getOrigin();
      if (!configRepos.hasMaterialWithFingerprint(origin.getMaterial().getFingerprint()))
        notToBeMerged.add(partialConfig);
    }
  }
  partList = ListUtils.removeAll(partList, notToBeMerged);
  return partList;
}
origin: terrier-org/terrier-core

static <T> List<List<T>> splitList(final List<T> all, final int k) {
  assert all.size() > 0;
  int size = all.size()/k;
  if (all.size() % k != 0)
    size++;
  List<List<T>> rtr = ListUtils.partition(all, size);
  //we can have no more than k partitions
  assert rtr.size() <= k;
  return rtr;
}
origin: org.apache.commons/commons-collections4

/**
 * Removes all values associated with the specified key.
 * <p>
 * A subsequent <code>get(Object)</code> would return an empty list.
 *
 * @param key  the key to remove values from
 * @return the <code>List</code> of values removed, will return an empty,
 *   unmodifiable list for no mapping found.
 */
@Override
public List<V> remove(final Object key) {
  return ListUtils.emptyIfNull(getMap().remove(key));
}
origin: kframework/k

@Override
public List<K> items() {
  if (frame != null) {
    return ListUtils.union(super.items(), Collections.singletonList(frame));
  } else {
    return super.items();
  }
}
origin: org.bitbucket.unaszole.xsdnormaliser/xmlstreameditor

public List<XMLElement> getChildren()
{
  return ListUtils.unmodifiableList(children);
}
public boolean isInDocument()
origin: CloudSlang/cloud-slang

/**
 * Displays a warning message for test suites that have rules defined for sequential or parallel execution
 * but are not in active test suites.
 *
 * @param testSuites          suite names contained in 'container' suites
 * @param testSuitesContained suite names contained in 'contained' suites
 * @param key                 run configuration property key
 */
private static void addWarningForSubsetOfRules(List<String> testSuites, List<String> testSuitesContained,
                        String key) {
  List<String> intersectWithContained = ListUtils.intersection(testSuites, testSuitesContained);
  if (intersectWithContained.size() != testSuitesContained.size()) {
    List<String> notScheduledForRun = new ArrayList<>(testSuitesContained);
    notScheduledForRun.removeAll(intersectWithContained);
    log.warn(format(MESSAGE_NOT_SCHEDULED_FOR_RUN_RULES, getListForPrint(notScheduledForRun), key));
  }
}
origin: com.sap.cloud.lm.sl.cf/com.sap.cloud.lm.sl.cf.process

private boolean shouldUpdateTags(CloudServiceExtended service, List<String> defaultTags, List<String> existingServiceTags) {
  if (service.isUserProvided()) {
    return false;
  }
  existingServiceTags = ObjectUtils.defaultIfNull(existingServiceTags, Collections.emptyList());
  existingServiceTags = ListUtils.removeAll(existingServiceTags, defaultTags);
  List<String> newServiceTags = ListUtils.removeAll(service.getTags(), defaultTags);
  return !existingServiceTags.equals(newServiceTags);
}
origin: drallieiv/KinanCity

logger.debug("Normal mode only check for {} captcha at once max", normalBatchSize);
Set<TwoCaptchaChallenge> fullList = challengesToResolve.stream().collect(Collectors.toSet());
batchList.addAll(ListUtils.partition(fullList.stream().collect(Collectors.toList()), normalBatchSize));
origin: BroadleafCommerce/BroadleafCommerce

/**
 * Converts a list of structured content items to a list of structured content DTOs.<br>
 * Internally calls buildStructuredContentDTO(...).
 *
 * @param structuredContentList
 * @param secure
 * @return
 * @see {@link #buildStructuredContentDTO(StructuredContent, boolean)}
 */
@Override
public List<StructuredContentDTO> buildStructuredContentDTOList(List<StructuredContent> structuredContentList, boolean secure) {
  List<StructuredContentDTO> dtoList = new ArrayList<>();
  structuredContentList = ListUtils.emptyIfNull(structuredContentList);
  for (StructuredContent sc : structuredContentList) {
    dtoList.add(buildStructuredContentDTO(sc, secure));
  }
  return dtoList;
}
origin: CloudSlang/cloud-slang

/**
 * Displays an informative message in case there is at least one test suite left for default run mode.
 *
 * @param unspecifiedTestSuiteRunMode the default run mode for suites that don't explicitly mention a run mode.
 * @param activeSuites                the suite names that are active
 * @param sequentialSuites            the suite names to be executed in sequential manner
 * @param parallelSuites              the suite names to be executed in parallel
 */
private static void addInformativeNoteForUnspecifiedRules(final TestCaseRunMode unspecifiedTestSuiteRunMode,
                             final List<String> activeSuites,
                             final List<String> sequentialSuites,
                             final List<String> parallelSuites) {
  List<String> union = union(sequentialSuites, parallelSuites);
  if (!union.containsAll(activeSuites)) {
    List<String> copy = new ArrayList<>(activeSuites);
    copy.removeAll(union);
    log.info(format(MESSAGE_TEST_SUITES_WITH_UNSPECIFIED_MAPPING,
        getListForPrint(copy), unspecifiedTestSuiteRunMode.name()));
  }
}
org.apache.commons.collections4ListUtils

Javadoc

Provides utility methods and decorators for List instances.

Most used methods

  • emptyIfNull
    Returns an immutable empty list if the argument is null, or the argument itself otherwise.
  • union
    Returns a new list containing the second list appended to the first list. The List#addAll(Collection
  • unmodifiableList
    Returns an unmodifiable list backed by the given list. This method uses the implementation in the de
  • intersection
    Returns a new list containing all elements that are contained in both given lists.
  • removeAll
    Removes the elements in remove from collection. That is, this method returns a list containing all t
  • partition
    Returns consecutive List#subList(int,int) of a list, each of the same size (the final list may be sm
  • isEqualList
    Tests two lists for value-equality as per the equality contract in java.util.List#equals(java.lang.O
  • subtract
    Subtracts all elements in the second list from the first list, placing the results in a new list. Th
  • select
    Selects all elements from input collection which match the given predicate into an output list. A nu
  • indexOf
    Finds the first index in the given List which matches the given predicate. If the input List or pred
  • longestCommonSubsequence
    Returns the longest common subsequence (LCS) of two sequences (lists).
  • defaultIfNull
    Returns either the passed in list, or if the list is null, the value of defaultList.
  • longestCommonSubsequence,
  • defaultIfNull,
  • retainAll,
  • sum

Popular in Java

  • Making http requests using okhttp
  • scheduleAtFixedRate (Timer)
  • startActivity (Activity)
  • getApplicationContext (Context)
  • String (java.lang)
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now