@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; } }
/** * 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)); }
/** * {@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)); }
/** * 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; }
/** * @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)); }
List<String> nextPermittedValues = ListUtils.intersection(nextRequestedValues, nextAllowedValues); if (nextPermittedValues.size() > 0) { restrictedExistingList = true;
/** * 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); }
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; }
List<RiskLevelRule> allRules = ListUtils.union(triageConfig.getRiskLevelRules(), newRules); triageConfig.setRiskLevelRules(allRules);
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(); } }
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; }
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; }
/** * 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)); }
@Override public List<K> items() { if (frame != null) { return ListUtils.union(super.items(), Collections.singletonList(frame)); } else { return super.items(); } }
public List<XMLElement> getChildren() { return ListUtils.unmodifiableList(children); } public boolean isInDocument()
/** * 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)); } }
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); }
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));
/** * 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; }
/** * 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())); } }