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

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

Introduction

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

Prototype

public static boolean containsAny(final Collection coll1, final Collection coll2) 

Source Link

Document

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

Usage

From source file:biz.netcentric.cq.tools.actool.validators.YamlConfigurationsValidator.java

@Override
public void validateDuplicateAuthorizables(final Set<String> groupsFromAllConfig,
        final Set<String> groupsFromCurrentConfig, final String configPath) throws IllegalArgumentException {

    if (CollectionUtils.containsAny(groupsFromAllConfig, groupsFromCurrentConfig)) {
        String errorMessage = "Already defined authorizable: ";

        // find the name of the doubled defined group and add it to error
        // message
        for (String group : groupsFromCurrentConfig) {
            if (groupsFromAllConfig.contains(group)) {
                errorMessage = errorMessage + group + " found in configuration file: " + configPath + "!";
                errorMessage += " This authorizable was already defined in another configuration file on the system!";
                break;
            }//from  w  w  w  .java2 s.c  o  m
        }
        throw new IllegalArgumentException(errorMessage);
    }
}

From source file:com.google.mr4c.keys.KeyTransformer.java

public synchronized DataKey transformKey(DataKey key) {
    if (!CollectionUtils.containsAny(key.getDimensions(), m_dims.keySet())) {
        return key; // no dim in this key has a transform
    }//  w w  w.ja  v  a2 s .c  o  m
    Set<DataKeyElement> newElements = new HashSet<DataKeyElement>();
    for (DataKeyDimension dim : key.getDimensions()) {
        DataKeyElement element = key.getElement(dim);
        ElementTransformer trans = m_dims.get(dim);
        DataKeyElement newElement = trans == null ? element : trans.transformElement(element);
        newElements.add(newElement);
    }
    return DataKeyFactory.newKey(newElements);
}

From source file:com.adobe.acs.commons.httpcache.rule.impl.HonorCacheControlHeaders.java

@Override
public boolean onResponseCache(SlingHttpServletRequest request, SlingHttpServletResponse response,
        HttpCacheConfig cacheConfig, CacheContent cacheContent) {
    // Check cache control header
    if (cacheContent.getHeaders().containsKey(KEY_CACHE_CONTROL_HEADER)) {
        List<String> cacheControlValues = cacheContent.getHeaders().get(KEY_CACHE_CONTROL_HEADER);
        if (CollectionUtils.containsAny(cacheControlValues, Arrays.asList(VALUES_CACHE_CONTROL))) {
            return false;
        }// w ww .  j a va  2  s  .c  o m
    }

    // Check Pragma.
    if (cacheContent.getHeaders().containsKey(KEY_PRAGMA)) {
        List<String> pragmaValues = cacheContent.getHeaders().get(KEY_PRAGMA);
        if (CollectionUtils.containsAny(pragmaValues, Arrays.asList(VALUES_PRAGMA))) {
            return false;
        }
    }

    return true;
}

From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.ListShiftsToImportLessonPlanningsProvider.java

@Override
public Object provide(Object source, Object currentValue) {

    ImportLessonPlanningsBean bean = (ImportLessonPlanningsBean) source;
    Set<Shift> shifts = new TreeSet<Shift>(Shift.SHIFT_COMPARATOR_BY_TYPE_AND_ORDERED_LESSONS);

    ExecutionCourse executionCourseFrom = bean.getExecutionCourse();
    ExecutionCourse executionCourseTo = bean.getExecutionCourseTo();

    if (executionCourseFrom != null && executionCourseTo != null) {

        List<ShiftType> shiftTypesTo = new ArrayList<ShiftType>();
        for (ShiftType shiftType : executionCourseTo.getShiftTypes()) {
            if (executionCourseTo.hasCourseLoadForType(shiftType)) {
                shiftTypesTo.add(shiftType);
            }/*from   ww w  .  ja va 2  s  . c om*/
        }

        for (Shift shift : executionCourseFrom.getAssociatedShifts()) {
            if (CollectionUtils.containsAny(shiftTypesTo, shift.getTypes())) {
                shifts.add(shift);
            }
        }

        if (shifts.isEmpty()) {
            return executionCourseFrom.getAssociatedShifts();
        }
    }

    return shifts;
}

From source file:com.pedra.core.strategies.impl.PedraSizeProductReferenceTargetStrategy.java

@Override
public ProductModel getTarget(final ProductModel sourceProduct, final ProductReferenceModel reference) {
    if (sourceProduct instanceof PedraSizeVariantProductModel
            && reference.getTarget() instanceof PedraStyleVariantProductModel) {
        final List<CategoryModel> sourceSuperCategories = getSuperCategoriesOfType(sourceProduct);
        final List<CategoryModel> targetSuperCategories = getSuperCategoriesOfType(reference.getTarget());
        if (CollectionUtils.containsAny(sourceSuperCategories, targetSuperCategories)) {
            // matching taxonomy categories so try a size map
            final String size = ((PedraSizeVariantProductModel) sourceProduct).getSize();
            for (final VariantProductModel variant : reference.getTarget().getVariants()) {
                if (variant instanceof PedraSizeVariantProductModel
                        && size.equals(((PedraSizeVariantProductModel) variant).getSize())) {
                    return variant;
                }//www .  jav  a  2s . co  m
            }
        }
    }
    return null;
}

From source file:cec.easyshop.core.strategies.impl.ApparelSizeProductReferenceTargetStrategy.java

@Override
public ProductModel getTarget(final ProductModel sourceProduct, final ProductReferenceModel reference) {
    if (sourceProduct instanceof ApparelSizeVariantProductModel
            && reference.getTarget() instanceof ApparelStyleVariantProductModel) {
        final List<CategoryModel> sourceSuperCategories = getSuperCategoriesOfType(sourceProduct);
        final List<CategoryModel> targetSuperCategories = getSuperCategoriesOfType(reference.getTarget());
        if (CollectionUtils.containsAny(sourceSuperCategories, targetSuperCategories)) {
            // matching taxonomy categories so try a size map
            final String size = ((ApparelSizeVariantProductModel) sourceProduct).getSize();
            for (final VariantProductModel variant : reference.getTarget().getVariants()) {
                if (variant instanceof ApparelSizeVariantProductModel
                        && size.equals(((ApparelSizeVariantProductModel) variant).getSize())) {
                    return variant;
                }/*from  w ww  . j a v a2s .c  o  m*/
            }
        }
    }
    return null;
}

From source file:com.ctc.core.strategies.impl.ApparelSizeProductReferenceTargetStrategy.java

@Override
public ProductModel getTarget(final ProductModel sourceProduct, final ProductReferenceModel reference) {
    VariantProductModel variant = null;//from  w ww.  j  av a2 s.  co m
    if (sourceProduct instanceof ApparelSizeVariantProductModel
            && reference.getTarget() instanceof ApparelStyleVariantProductModel) {
        final List<CategoryModel> sourceSuperCategories = getSuperCategoriesOfType(sourceProduct);
        final List<CategoryModel> targetSuperCategories = getSuperCategoriesOfType(reference.getTarget());
        if (CollectionUtils.containsAny(sourceSuperCategories, targetSuperCategories)) {
            // matching taxonomy categories so try a size map
            final String size = ((ApparelSizeVariantProductModel) sourceProduct).getSize();
            variant = getVariantWithSameSize(reference, size);
        }
    }
    return variant;
}

From source file:info.magnolia.ui.framework.availability.shorthandrules.AccessGrantedRule.java

@Override
public boolean isAvailable(Collection<?> itemIds) {
    User user = MgnlContext.getUser();/*from   w  w  w . j  av a  2  s  .c om*/
    // Validate that the user has all the required roles
    Collection<String> userRoles = user.getAllRoles();
    Collection<String> roles = accessDefinition.getRoles();
    if (roles.isEmpty() || userRoles.contains(DEFAULT_SUPERUSER_ROLE)
            || CollectionUtils.containsAny(userRoles, roles)) {
        return true;
    }
    return false;
}

From source file:br.com.emsouza.plugin.validate.ValidatePomMojo.java

@Override
public void execute() throws MojoExecutionException, MojoFailureException {

    boolean execute = Boolean.parseBoolean(project.getProperties().getProperty("validate-plugin", "true"));

    if (execute) {
        if (!project.getPackaging().equals("pom")) {

            List<Dependency> dependencies = ConvertData.readProjectFile(pomFile);
            Configuration cfg = ConfigurationFactory.build(configURL);

            // Get the list of valid scopes
            if (!ValidateScopeUtil.isValid(dependencies, cfg.getScopes())) {
                throw new MojoFailureException(
                        "Existem dependncias declaradas fora do padro => " + mavenDocURL);
            }/*from w  w w .  j  a  v a  2  s  .c o  m*/

            // Verify exclude artifact
            if (CollectionUtils.containsAny(dependencies, cfg.getExclusions())) {
                Dependency art = (Dependency) ListUtils.intersection(dependencies, cfg.getExclusions()).get(0);
                throw new MojoFailureException(String.format(art.getDescription(), art));
            }

            // Verify correct Syntax
            ValidateSyntaxUtil.validate(dependencies, cfg.getSyntax());
        }
    }
}

From source file:com.agiletec.plugins.jpcrowdsourcing.aps.system.services.common.api.CollaborationAbstractApiInterface.java

public boolean isAuthOnInstance(UserDetails user, IdeaInstance instance) {
    boolean auth = false;
    Collection<String> groupCodes = this.extractGroups(user);
    if (CollectionUtils.containsAny(groupCodes, instance.getGroups())) {
        auth = true;//from  w  ww  .ja  v a 2  s .c o  m
    }
    return auth;
}