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

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

Introduction

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

Prototype

public static Collection retainAll(Collection collection, Collection retain) 

Source Link

Document

Returns a collection containing all the elements in collection that are also in retain.

Usage

From source file:nl.strohalm.cyclos.services.access.AccessServiceImpl.java

@SuppressWarnings("unchecked")
@Override/*ww  w .j  a v  a  2  s.c  o m*/
public Collection<Channel> getChannelsEnabledForMember(Member member) {
    member = fetchService.fetch(member, Element.Relationships.GROUP);
    return CollectionUtils.retainAll(member.getChannels(), member.getMemberGroup().getChannels());
}

From source file:org.cloudfoundry.identity.uaa.login.saml.LoginSamlAuthenticationProvider.java

private Set<String> filterSamlAuthorities(SamlIdentityProviderDefinition definition,
        Collection<? extends GrantedAuthority> samlAuthorities) {
    List<String> whiteList = Collections.EMPTY_LIST;
    if (definition != null && definition.getExternalGroupsWhitelist() != null) {
        whiteList = definition.getExternalGroupsWhitelist();
    }/* w  w w  .  j  a va  2 s .c  om*/
    Set<String> authorities = samlAuthorities.stream().map(s -> s.getAuthority()).collect(Collectors.toSet());

    return new HashSet<>(CollectionUtils.retainAll(authorities, whiteList));
}

From source file:org.squashtest.tm.service.internal.testcase.TestCaseLibraryNavigationServiceImpl.java

@SuppressWarnings("unchecked")
private Collection<Long> filterTcIdsListsByMilestone(Collection<Long> tcIds, Milestone activeMilestone) {

    List<Long> tcInMilestone = findAllTestCasesLibraryNodeForMilestone(activeMilestone);
    return CollectionUtils.retainAll(tcIds, tcInMilestone);
}

From source file:org.squashtest.tm.web.internal.controller.milestone.MilestoneController.java

@RequestMapping(params = "selectable", method = RequestMethod.GET)
@ResponseBody/*  w  w  w .  j  a v  a 2  s .co m*/
public DataTableModel<Milestone> findUserSelectableMilestones() {

    List<Milestone> milestones = milestoneFinder.findAllVisibleToCurrentUser();

    //checking global project filter and filter milestone who aren't binded to at least one project in filter
    ProjectFilter projectFilter = projectFilterService.findProjectFilterByUserLogin();
    if (projectFilter.isEnabled()) {
        Collection<Milestone> milestonesCollection = CollectionUtils.retainAll(milestones,
                getMilestoneFromProjectFilter(projectFilter));
        milestones = new ArrayList<>(0);
        milestones.addAll(milestonesCollection);
    }

    // they must be initially sorted by date descending
    Collections.sort(milestones, new Comparator<Milestone>() {
        @Override
        public int compare(Milestone o1, Milestone o2) {
            return o2.getEndDate().before(o1.getEndDate()) ? -1 : 1;
        }
    });

    // now make the model
    PagedCollectionHolder<List<Milestone>> holderCollection = new SinglePageCollectionHolder<>(milestones);

    Locale locale = LocaleContextHolder.getLocale();
    return new MilestoneTableModelHelper(i18nHelper, locale).buildDataModel(holderCollection, "0");

}