List of usage examples for org.apache.commons.collections CollectionUtils union
public static Collection union(final Collection a, final Collection b)
From source file:net.sourceforge.atunes.kernel.modules.search.OrLogicalSearchOperator.java
@SuppressWarnings("unchecked") @Override//from w ww. j a v a2 s.c o m public Collection<IAudioObject> evaluate(List<ISearchNode> operands) { Collection<IAudioObject> union = null; for (ISearchNode operand : operands) { Collection<IAudioObject> operandResult = operand.evaluate(); if (operandResult != null) { if (union == null) { union = operandResult; } else { union = CollectionUtils.union(union, operandResult); } } } return union; }
From source file:com.mac.holdempoker.app.hands.Pair.java
private Card[] findPair() { List<Card> pair = new ArrayList(); List<Card> singles = new ArrayList(); for (Map.Entry<Rank, List<Card>> entry : cards.entrySet()) { if (entry.getValue().size() == 2 && pair.isEmpty()) { pair = entry.getValue();/*from w w w . jav a 2s . co m*/ } else if (entry.getValue().size() == 1 && singles.size() < 3) { singles.add(entry.getValue().get(0)); } } if (pair.size() == 2 && singles.size() == 3) { return (Card[]) CollectionUtils.union(pair, singles).toArray(new Card[5]); } else { return null; } }
From source file:com.mac.holdempoker.app.hands.Set.java
private Card[] findSet() { List<Card> trips = new ArrayList(); List<Card> singles = new ArrayList(); for (Map.Entry<Rank, List<Card>> entry : cards.entrySet()) { if (entry.getValue().size() == 3 && trips.size() == 0) { trips = entry.getValue();//from w w w .jav a 2s . com } else if (entry.getValue().size() == 1 && singles.size() < 2) { singles.add(entry.getValue().get(0)); } } if (trips.size() == 3 && singles.size() == 2) { return (Card[]) CollectionUtils.union(trips, singles).toArray(new Card[5]); } else { return null; } }
From source file:edu.uci.ics.jung.graph.impl.SimpleSparseVertex.java
/** * @see Vertex#getPredecessors()/*from www. j a v a 2s .c o m*/ */ public Set getPredecessors() { Collection preds = CollectionUtils.union(getPredsToInEdges().keySet(), getNeighborsToEdges().keySet()); return Collections.unmodifiableSet(new HashSet(preds)); }
From source file:edu.uci.ics.jung.graph.impl.SimpleSparseVertex.java
/** * @see Vertex#getSuccessors()//w ww . ja va2 s. c o m */ public Set getSuccessors() { Collection succs = CollectionUtils.union(getSuccsToOutEdges().keySet(), getNeighborsToEdges().keySet()); return Collections.unmodifiableSet(new HashSet(succs)); }
@Atomic public static InfoCurriculum run(Integer executionDegreeCode, String curricularCourseCode, String stringExecutionYear) throws FenixServiceException { check(RolePredicates.COORDINATOR_PREDICATE); InfoCurriculum infoCurriculum = null; if (curricularCourseCode == null) { throw new FenixServiceException("nullCurricularCourse"); }/*from w w w. j a va2 s. co m*/ if (stringExecutionYear == null || stringExecutionYear.length() == 0) { throw new FenixServiceException("nullExecutionYearName"); } CurricularCourse curricularCourse = (CurricularCourse) FenixFramework.getDomainObject(curricularCourseCode); if (curricularCourse == null) { throw new NonExistingServiceException("noCurricularCourse"); } final ExecutionYear executionYear = ExecutionYear.readExecutionYearByName(stringExecutionYear); if (executionYear == null) { throw new NonExistingServiceException("noExecutionYear"); } Curriculum curriculumExecutionYear = curricularCourse .findLatestCurriculumModifiedBefore(executionYear.getEndDate()); if (curriculumExecutionYear != null) { List allCurricularCourseScopes = new ArrayList(); List allExecutionCourses = new ArrayList(); Collection executionPeriods = executionYear.getExecutionPeriodsSet(); Iterator iterExecutionPeriods = executionPeriods.iterator(); while (iterExecutionPeriods.hasNext()) { ExecutionSemester executionSemester = (ExecutionSemester) iterExecutionPeriods.next(); Set<CurricularCourseScope> curricularCourseScopes = curricularCourse .findCurricularCourseScopesIntersectingPeriod(executionSemester.getBeginDate(), executionSemester.getEndDate()); if (curricularCourseScopes != null) { List disjunctionCurricularCourseScopes = (List) CollectionUtils .disjunction(allCurricularCourseScopes, curricularCourseScopes); List intersectionCurricularCourseScopes = (List) CollectionUtils .intersection(allCurricularCourseScopes, curricularCourseScopes); allCurricularCourseScopes = (List) CollectionUtils.union(disjunctionCurricularCourseScopes, intersectionCurricularCourseScopes); } List associatedExecutionCourses = new ArrayList(); Collection<ExecutionCourse> executionCourses = curricularCourse.getAssociatedExecutionCoursesSet(); for (ExecutionCourse executionCourse : executionCourses) { if (executionCourse.getExecutionPeriod().equals(executionSemester)) { associatedExecutionCourses.add(executionCourse); } } if (associatedExecutionCourses != null) { allExecutionCourses.addAll(associatedExecutionCourses); } } infoCurriculum = createInfoCurriculum(curriculumExecutionYear, allCurricularCourseScopes, allExecutionCourses); } return infoCurriculum; }
From source file:net.sf.firemox.token.CardPropertiesOperation.java
/** * Return the result operation result applied on the given properties. * /*from w w w. jav a 2s. c o m*/ * @param properties * first properties set. * @param properties2 * second properties set. * @param lower * The minimal property value included used by the operation. * @param higher * The maximal property value included used by the operation. * @return the result operation result applied on the given properties. */ @SuppressWarnings("unchecked") public int getValue(Set<Integer> properties, Set<Integer> properties2, int lower, int higher) { final Collection<Integer> workingSet; switch (this) { case INTERSECTION_SIZE: workingSet = CollectionUtils.intersection(properties, properties2); break; case UNION_SIZE: workingSet = CollectionUtils.union(properties, properties2); break; case DISJONCTION_SIZE: workingSet = CollectionUtils.disjunction(properties, properties2); break; default: Log.fatal("Unhandled CardPropertiesOperation +" + this); workingSet = new ArrayList<Integer>(); } int count = workingSet.size(); for (Integer value : workingSet) { if (value < lower || higher > value) { count--; } } return count; }
From source file:com.adaptris.core.runtime.WorkflowManager.java
private void initMembers() throws MalformedObjectNameException, CoreException { if (isEmpty(managedWorkflow.getUniqueId())) { throw new CoreException("No UniqueID, this workflow cannot be managed"); }/*from ww w.java 2 s . c o m*/ // Builds up a name com.adaptris:type=Workflow, adapter=<adapter-id,>, id=<channel-id>, workflow=<workflow-id> myObjectName = ObjectName.getInstance( JMX_WORKFLOW_TYPE + ADAPTER_PREFIX + getParent().getParent().getUniqueId() + CHANNEL_PREFIX + getParent().getUniqueId() + ID_PREFIX + getWrappedComponent().getUniqueId()); configureDefaultInterceptors(); Collection<AdaptrisComponent> runtimeCandidates = CollectionUtils.union(managedWorkflow.getInterceptors(), Arrays.asList(new AdaptrisComponent[] { managedWorkflow.getConsumer(), managedWorkflow.getProducer(), defaultIfNull(managedWorkflow.getMessageErrorHandler()) })); for (AdaptrisComponent c : runtimeCandidates) { addChildJmxComponentQuietly((ChildRuntimeInfoComponent) RuntimeInfoComponentFactory.create(this, c)); } marshalConfig(); }
From source file:com.zuora.api.object.Dynamic.java
public Collection<Entry<String, Object>> properties() { return CollectionUtils.union(staticProperties(), dynamicProperties()); }
From source file:com.evolveum.midpoint.model.impl.lens.EvaluationOrderImpl.java
@Override public Map<QName, Integer> diff(EvaluationOrder newState) { if (!newState.isDefined()) { throw new IllegalArgumentException("Cannot compute diff to undefined evaluation order"); }//from www . j a v a 2 s . com @SuppressWarnings({ "unchecked", "raw" }) Collection<QName> relations = CollectionUtils.union(getRelations(), newState.getRelations()); Map<QName, Integer> rv = new HashMap<>(); // relation is not null below relations.forEach(relation -> rv.put(relation, newState.getMatchingRelationOrder(relation) - getMatchingRelationOrder(relation))); return rv; }