public void testDisjunction() { Collection col = CollectionUtils.disjunction(collectionA,collectionB); Map freq = CollectionUtils.getCardinalityMap(col); assertEquals(new Integer(1),freq.get("a")); assertEquals(new Integer(2),freq.get("b")); assertNull(freq.get("c")); assertEquals(new Integer(2),freq.get("d")); assertEquals(new Integer(1),freq.get("e")); Collection col2 = CollectionUtils.disjunction(collectionB,collectionA); Map freq2 = CollectionUtils.getCardinalityMap(col2); assertEquals(new Integer(1),freq2.get("a")); assertEquals(new Integer(2),freq2.get("b")); assertNull(freq2.get("c")); assertEquals(new Integer(2),freq2.get("d")); assertEquals(new Integer(1),freq2.get("e")); }
public void testDisjunctionAsUnionMinusIntersection() { Collection dis = CollectionUtils.disjunction(collectionA,collectionB); Collection un = CollectionUtils.union(collectionA,collectionB); Collection inter = CollectionUtils.intersection(collectionA,collectionB); assertTrue(CollectionUtils.isEqualCollection(dis,CollectionUtils.subtract(un,inter))); }
public void testDisjunctionAsSymmetricDifference() { Collection dis = CollectionUtils.disjunction(collectionA,collectionB); Collection amb = CollectionUtils.subtract(collectionA,collectionB); Collection bma = CollectionUtils.subtract(collectionB,collectionA); assertTrue(CollectionUtils.isEqualCollection(dis,CollectionUtils.union(amb,bma))); }
public static void main(String[] aaa) { String input = "[INFO] Running ca.uhn.fhir.rest.client.RestfulClientFactoryDstu2Test\n" + "[INFO] Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.982 s - in ca.uhn.fhir.validation.ResourceValidatorDstu2Test"; Set<String> started = new HashSet<>(); Set<String> finished = new HashSet<>(); for (String next : input.split("\n")) { if (next.startsWith("[INFO] ")) { next = next.substring("[INFO] ".length()); } if (next.startsWith("[WARNING] ")) { next = next.substring("[WARNING] ".length()); } if (next.startsWith("Running ")) { started.add(next.substring("Running ".length())); } else if (next.startsWith("Tests run: ")) { finished.add(next.substring(next.indexOf(" - in ") + " - in ".length())); } else if (isBlank(next)) { continue; } else { throw new IllegalStateException("Unknown line: " + next); } } ourLog.info("Started {}", started.size()); ourLog.info("Finished {}", finished.size()); ourLog.info(CollectionUtils.disjunction(started, finished).toString()); }
private void validateErrorMappings() { executeOnEveryComponentTree(componentModel -> { List<ComponentModel> errorMappings = componentModel.getInnerComponents().stream() .filter(c -> c.getIdentifier().equals(ERROR_MAPPING_IDENTIFIER)).collect(toList()); if (!errorMappings.isEmpty()) { List<ComponentModel> anyMappings = errorMappings.stream().filter(this::isErrorMappingWithSourceAny).collect(toList()); if (anyMappings.size() > 1) { throw new MuleRuntimeException(createStaticMessage("Only one mapping for 'ANY' or an empty source type is allowed.")); } else if (anyMappings.size() == 1 && !isErrorMappingWithSourceAny(errorMappings.get(errorMappings.size() - 1))) { throw new MuleRuntimeException(createStaticMessage("Only the last error mapping can have 'ANY' or an empty source type.")); } List<String> sources = errorMappings.stream().map(model -> model.getParameters().get(SOURCE_TYPE)).collect(toList()); List<String> distinctSources = sources.stream().distinct().collect(toList()); if (sources.size() != distinctSources.size()) { throw new MuleRuntimeException(createStaticMessage(format("Repeated source types are not allowed. Offending types are '%s'.", on("', '").join(disjunction(sources, distinctSources))))); } } }); }
/** * Returns those element that are contained in only one of both collections. * @param first * @param second * @return CollectionUtils.disjunction(first, second) */ public static Collection symmetricDifference( final Collection first, final Collection second) { return CollectionUtils.disjunction(first, second); }
@SuppressWarnings("unchecked") @Override public PowerList<E> getDisjunction(Collection<E> list) { return powerList(CollectionUtils.disjunction(this, list)); }
@SuppressWarnings("unchecked") public PowerSet<E> getDisjunction(Collection<E> Set) { return powerSet(CollectionUtils.disjunction(this, Set)); }
@SuppressWarnings( "unchecked" ) private Set<String> findDuplicateDependencies( List<Dependency> modelDependencies ) { List<String> modelDependencies2 = new ArrayList<String>(); for ( Dependency dep : modelDependencies ) { modelDependencies2.add( dep.getManagementKey() ); } //@formatter:off return new LinkedHashSet<String>( CollectionUtils.disjunction( modelDependencies2, new LinkedHashSet<String>( modelDependencies2 ) ) ); //@formatter:on } }
private List<PhdIndividualProgramProcess> getStudentOtherProcesses(final PhdIndividualProgramProcess process) { List<PhdIndividualProgramProcess> result = new ArrayList<PhdIndividualProgramProcess>(); result.addAll(CollectionUtils.disjunction(process.getPerson().getPhdIndividualProgramProcessesSet(), Collections.singletonList(process))); return result; }
@Test public void shouldAllowEditingADiscontinuationOrder() { Order originalDCOrder = orderService.getOrder(22); assertEquals(Order.Action.DISCONTINUE, originalDCOrder.getAction()); List<Order> originalPatientOrders = orderService.getAllOrdersByPatient(originalDCOrder.getPatient()); final Order previousOrder = originalDCOrder.getPreviousOrder(); assertNotNull(previousOrder); final Date newStartDate = originalDCOrder.getEncounter().getEncounterDatetime(); Order newDcOrder = originalDCOrder.cloneForRevision(); newDcOrder.setEncounter(originalDCOrder.getEncounter()); newDcOrder.setOrderer(originalDCOrder.getOrderer()); newDcOrder.setDateActivated(newStartDate); orderService.voidOrder(originalDCOrder, "To be replace with a new one"); assertNull(originalDCOrder.getDateStopped()); orderService.saveOrder(newDcOrder, null); //We need to flush so that we ensure the interceptor is okay with all this Context.flushSession(); assertTrue(originalDCOrder.getVoided()); List<Order> newPatientOrders = orderService.getAllOrdersByPatient(originalDCOrder.getPatient()); assertEquals(originalPatientOrders.size() + 1, newPatientOrders.size()); Collection<Order> newOrders = CollectionUtils.disjunction(originalPatientOrders, newPatientOrders); assertEquals(1, newOrders.size()); assertEquals(newOrders.iterator().next().getPreviousOrder(), previousOrder); }
protected static Set<? extends SInstance> collectLowerBoundInstances(FeedbackFence feedbackFence) { // coleta os componentes descendentes que possuem um handler, e as instancias correspondentes final Set<Component> mainComponents = collectLowerBoundInstances(feedbackFence.getMainContainer()); final Set<Component> externalComponents = collectLowerBoundInstances(feedbackFence.getExternalContainer()); return ((Collection<Component>) CollectionUtils.disjunction(mainComponents, externalComponents)).stream() .flatMap(it -> resolveRootInstances(it).stream()) .collect(toSet()); }
private void validateErrorMappings() { executeOnEveryComponentTree(componentModel -> { List<ComponentModel> errorMappings = componentModel.getInnerComponents().stream() .filter(c -> c.getIdentifier().equals(ERROR_MAPPING_IDENTIFIER)).collect(toList()); if (!errorMappings.isEmpty()) { List<ComponentModel> anyMappings = errorMappings.stream().filter(this::isErrorMappingWithSourceAny).collect(toList()); if (anyMappings.size() > 1) { throw new MuleRuntimeException(createStaticMessage("Only one mapping for 'ANY' or an empty source type is allowed.")); } else if (anyMappings.size() == 1 && !isErrorMappingWithSourceAny(errorMappings.get(errorMappings.size() - 1))) { throw new MuleRuntimeException(createStaticMessage("Only the last error mapping can have 'ANY' or an empty source type.")); } List<String> sources = errorMappings.stream().map(model -> model.getParameters().get(SOURCE_TYPE)).collect(toList()); List<String> distinctSources = sources.stream().distinct().collect(toList()); if (sources.size() != distinctSources.size()) { throw new MuleRuntimeException(createStaticMessage(format("Repeated source types are not allowed. Offending types are '%s'.", on("', '").join(disjunction(sources, distinctSources))))); } } }); }
private Collection<Long> getChangedProjectIds() { List<Project> previousProjects = getConfigScheme().getAssociatedProjectObjects(); List<Long> previousProjectIds; if (previousProjects != null && !previousProjects.isEmpty()) { previousProjectIds = Lists.newArrayList(Iterables.transform(previousProjects, WithFunctions.getId())); } else { previousProjectIds = Collections.emptyList(); } List<Long> newProjectIds; if (getProjects() != null && getProjects().length > 0) { newProjectIds = Arrays.asList(getProjects()); } else { newProjectIds = Collections.emptyList(); } Collection<Long> affectedProjectIds = CollectionUtils.disjunction(previousProjectIds, newProjectIds); return affectedProjectIds; } }
Collection<String> invalidRootPageNames = CollectionUtils.<String>disjunction(rootPageNames, validRootPageNames); return new ValidatedRootPages(invalidRootPageNames, validRootPageNames, includedRootPages);
String[] symDiff = new ArrayList<String>(CollectionUtils.disjunction( instanceFeatureNames, featureNames)).toArray(new String[] {});
public boolean isAssociatedWithEmailAndCandidacyProcess(String email, Class<? extends IndividualCandidacyProcess> type, CandidacyProcess process, List<Degree> degreeList) { if (email.equals(this.getEmail()) && this.getIndividualCandidacyProcess() != null && !getIndividualCandidacyProcess().isCandidacyCancelled() && this.getIndividualCandidacyProcess().getClass() == type && this.getIndividualCandidacyProcess().getCandidacyProcess() == process) { return CollectionUtils.disjunction(this.getIndividualCandidacyProcess().getCandidacy().getAllDegrees(), degreeList) .isEmpty(); } else { return false; } }
private void assertGetAllForConnectionResult(List<StorageServerConnections> expected, StorageServerConnections forQuery) { assertTrue(CollectionUtils.disjunction(expected, dao.getAllForConnection(forQuery)).isEmpty()); }
@Test public void testGetAllForStoragePoolAndStatuses() { prepareHostWithDifferentStatus(); List<VDS> result = dao.getAllForStoragePoolAndStatuses(existingVds.getStoragePoolId(), EnumSet.of(existingVds.getStatus(), existingVds2.getStatus())); assertTrue(CollectionUtils.disjunction(result, Arrays.asList(existingVds, existingVds2)).isEmpty()); assertCorrectGetAllResult(result); }
/** * Returns the difference between two sheets. Note that T must implement * hashCode() and equals() if you wish to have meaningful symmetric difference * results. * * @param a the first sheet * @param b the second sheet * @param reportGenerator a custom reporter implementation * @return DiffResult object which holds the diff result */ @SuppressWarnings("unchecked") public static <T> DiffResult<T> diff(@Nonnull SheetReader<T> a, @Nonnull SheetReader<T> b, ReportGenerator reportGenerator) { Collection<T> ca = a.read(); Collection<T> cb = b.read(); Collection<T> disjunction = CollectionUtils.disjunction(ca, cb); Info<T> info = new ReportInfo<T>(new Files(a.getSheet().getFile().getAbsolutePath(), b.getSheet().getFile() .getAbsolutePath()), new Sheets(a.getSheet().getNativeSheet().getSheetName(), b.getSheet().getNativeSheet() .getSheetName()), new Collections<T>(ca, cb, disjunction)); ReportGenerator reporter; if (reportGenerator != null) { reporter = reportGenerator; } else { reporter = new SimpleReportGenerator(); } return new DiffResultImpl<T>(disjunction, reporter.generateReport(info)); }