Example usage for org.apache.commons.collections15 CollectionUtils containsAny

List of usage examples for org.apache.commons.collections15 CollectionUtils containsAny

Introduction

In this page you can find the example usage for org.apache.commons.collections15 CollectionUtils containsAny.

Prototype

public static <E> boolean containsAny(final Collection<? extends E> coll1,
        final Collection<? extends E> coll2) 

Source Link

Document

Returns true iff at least one element is in both collections15.

Usage

From source file:logicProteinHypernetwork.networkStates.MinimalNetworkState.java

/**
 * Returns true if two minimal network states are clashing, thus if their entities
 * cannot appear simultaneously if they are their only minimal network states.
 * /*from ww w.  j  a  v a  2 s . c o m*/
 * @param s a minimal network state
 * @return whether they are clashing
 */
public boolean isClash(MinimalNetworkState s) {
    return CollectionUtils.containsAny(necessary, s.impossible)
            || CollectionUtils.containsAny(impossible, s.necessary);
}

From source file:edu.duke.cabig.c3pr.utils.SecurityUtils.java

/**
 * Checks if user has any of the provided roles.
 * // w w  w . j a va  2  s  .c om
 * @param authentication the authentication
 * @param roleTypes the role types
 * 
 * @return true, if successful
 */
public static boolean hasRole(Authentication authentication, List<RoleTypes> roleTypes) {
    if (roleTypes == null) {
        return false;
    }
    return CollectionUtils.containsAny(roleTypes, getRoleTypes(authentication));
}

From source file:edu.duke.cabig.c3pr.utils.SecurityUtils.java

/**
 * Checks if user has any of the provided privileges.
 * //from   w ww  . ja v a 2s. c om
 * @param privilegeTypes the privilege types
 * 
 * @return true, if successful
 */
public static boolean hasAnyPrivilege(List<UserPrivilegeType> privilegeTypes) {
    if (privilegeTypes == null) {
        return false;
    }
    List<UserPrivilege> privileges = new ArrayList<UserPrivilege>();
    for (UserPrivilegeType userPrivilegeType : privilegeTypes) {
        privileges.add(new UserPrivilege(userPrivilegeType.getCode()));
    }

    return CollectionUtils.containsAny(privileges, getUserPrivileges());
}

From source file:org.biopax.validator.rules.BiochemReactParticipantsLocationRule.java

public void check(final Validation validation, BiochemicalReaction react) {
    Set<PhysicalEntity> left = react.getLeft();
    Set<PhysicalEntity> right = react.getRight();
    for (PhysicalEntity lefty : left) {
        for (PhysicalEntity righty : right) {
            // PhysicalEntity is either Complex or SimplePhysicalEntity (NucleicAcid, Protein or SmallMolecule)

            if (!lefty.getModelInterface().equals(righty.getModelInterface())) {
                continue;
            }/*from  w w  w .  j  a va 2  s. co  m*/

            boolean sameComplex = (lefty instanceof Complex) // means - righty is also Complex
                    && CollectionUtils.containsAny(lefty.getName(), righty.getName());
            // Complex does not have entityReference to match the same kind on both sides...

            boolean sameSimplePhysicalEntity = (lefty instanceof SimplePhysicalEntity)
                    && (((SimplePhysicalEntity) lefty).getEntityReference() == null
                            ? ((SimplePhysicalEntity) righty).getEntityReference() == null
                            : ((SimplePhysicalEntity) lefty).getEntityReference()
                                    .isEquivalent(((SimplePhysicalEntity) righty).getEntityReference()));

            if (sameComplex || sameSimplePhysicalEntity) {
                boolean sameLoc = lefty.hasEquivalentCellularLocation(righty);
                if (!sameLoc && !(react instanceof Transport)) {
                    error(validation, react, "participant.location.changed", false, lefty, righty);
                } else if (sameLoc && react instanceof Transport) {
                    error(validation, react, "transport.location.same", false, lefty, righty);
                }
            }
        }
    }
}

From source file:org.biopax.validator.rules.SameNameDiffKindPhysEntitiesRule.java

public void check(final Validation validation, Model model) {
    Set<SimplePhysicalEntity> peers = new HashSet<SimplePhysicalEntity>(
            model.getObjects(SimplePhysicalEntity.class));

    Cluster<SimplePhysicalEntity> groupping = new Cluster<SimplePhysicalEntity>() {
        @Override//from w  w  w .  j  ava  2  s.  co m
        public boolean match(SimplePhysicalEntity a, SimplePhysicalEntity b) {
            return !a.equals(b) && a.getEntityReference() != null && !a.getName().isEmpty()
                    && !b.getName().isEmpty() && !a.getEntityReference().isEquivalent(b.getEntityReference())
                    && CollectionUtils.containsAny(a.getName(), b.getName());
        }
    };

    Set<Set<SimplePhysicalEntity>> sharedNamesClusters = groupping.cluster(peers, Integer.MAX_VALUE);

    // report the error once for each cluster
    for (Set<SimplePhysicalEntity> sharedNames : sharedNamesClusters) {
        if (sharedNames.size() > 1) {
            SimplePhysicalEntity a = sharedNames.iterator().next();
            error(validation, a, "diff.kind.same.name", false, sharedNames);
        }
    }
}

From source file:proteinHypernetworkVisualization.implementation.jung.visualization.JungProteinNetworkVisualization.java

public void highlightNetworkEntities(final HashSet<NetworkEntity> networkEntities) {
    final Transformer<Protein, Paint> vft = vv.getRenderContext().getVertexFillPaintTransformer();
    vv.getRenderContext().setVertexFillPaintTransformer(new Transformer<Protein, Paint>() {

        public Paint transform(Protein p) {
            if (networkEntities.contains(p) || CollectionUtils.containsAny(networkEntities,
                    vv.getGraphLayout().getGraph().getIncidentEdges(p))) {
                return Color.WHITE;
            }//from  w ww.  ja  v  a  2  s .  c  o m
            return vft.transform(p);
        }
    });

    /*final Transformer<Interaction, Paint> edt = vv.getRenderContext().getEdgeDrawPaintTransformer();
    vv.getRenderContext().setEdgeDrawPaintTransformer(new Transformer<Interaction, Paint>() {
            
    public Paint transform(Interaction i) {
    if(networkEntities.contains(i))
    return Color.WHITE;
    return edt.transform(i);
    }
    });*/
}