List of usage examples for org.apache.commons.collections CollectionUtils cardinality
public static int cardinality(Object obj, final Collection coll)
From source file:org.apache.oozie.workflow.lite.LiteWorkflowValidator.java
private void checkForkTransitions(LiteWorkflowApp app, List<String> transitionsList, NodeDef node) throws WorkflowException { for (final String t : transitionsList) { NodeDef aNode = app.getNode(t);// w ww . j a v a 2 s . c om // Now we have to figure out which node is the problem and what type of node they are (join and kill are ok) if (!(aNode instanceof JoinNodeDef) && !(aNode instanceof KillNodeDef)) { int count = CollectionUtils.cardinality(t, transitionsList); if (count > 1) { throw new WorkflowException(ErrorCode.E0744, node.getName(), t); } } } }
From source file:org.openvpms.web.component.im.query.QueryTestHelper.java
/** * Checks to see if an objects exists in a list of matches and that the {@link Query#selects} method agrees. * * @param object the object/*from w w w. ja v a2 s. co m*/ * @param query the query * @param matches the query results * @param exists determines if the object should exist or not */ public static <T extends IMObject> void checkExists(T object, Query<T> query, List<IMObjectReference> matches, boolean exists) { int cardinality = (exists) ? 1 : 0; assertEquals(cardinality, CollectionUtils.cardinality(object.getObjectReference(), matches)); assertEquals(exists, query.selects(object)); assertEquals(exists, query.selects(object.getObjectReference())); }