Java Code Examples for org.apache.commons.collections4.SetUtils#intersection()

The following examples show how to use org.apache.commons.collections4.SetUtils#intersection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReadOnlyParametersChecker.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
private void checkForCommonParameters(NamedParametersContainer namedParametersContainer, Set<String> readOnlyParameters,
                                      Map<String, Set<String>> commonReadOnlyParameters) {
    Set<String> commonParameters = SetUtils.intersection(namedParametersContainer.getParameters()
                                                                                 .keySet(), readOnlyParameters);
    if (!commonParameters.isEmpty()) {
        commonReadOnlyParameters.put(namedParametersContainer.getName(), commonParameters);
    }
}
 
Example 2
Source File: SetUtilsUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenTwoSets_whenIntersection_thenIntersectionResult() {
    Set<Integer> a = new HashSet<>(Arrays.asList(1, 2, 5));
    Set<Integer> b = new HashSet<>(Arrays.asList(1, 2));
    Set<Integer> expected = new HashSet<>(Arrays.asList(1, 2));
    SetUtils.SetView<Integer> intersect = SetUtils.intersection(a, b);
    assertTrue(SetUtils.isEqualSet(expected, intersect));
}
 
Example 3
Source File: SetOperationsUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Test
public void givenTwoSets_WhenWeUseApacheCommonsIntersect_ThenWeGetTheIntersect() {
    Set<Integer> intersectSet = SetUtils.intersection(setA, setB);
    assertEquals(setOf(2,4), intersectSet);
}