Java Code Examples for org.apache.commons.collections4.SetUtils#SetView

The following examples show how to use org.apache.commons.collections4.SetUtils#SetView . 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: SysRolePermissionServiceImpl.java    From spring-boot-plus with Apache License 2.0 5 votes vote down vote up
@Override
public boolean saveSysRolePermissionBatch(Long roleId, SetUtils.SetView addSet) {
    List<SysRolePermission> list = new ArrayList<>();
    addSet.forEach(id -> {
        SysRolePermission sysRolePermission = new SysRolePermission();
        Long permissionId = (Long) id;
        sysRolePermission
                .setRoleId(roleId)
                .setPermissionId(permissionId)
                .setState(StateEnum.ENABLE.getCode());
        list.add(sysRolePermission);
    });
    return saveBatch(list, 20);
}
 
Example 2
Source File: SetUtilsUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenTwoSets_whenDifference_thenSetView() {
    Set<Integer> a = new HashSet<>(Arrays.asList(1, 2, 5));
    Set<Integer> b = new HashSet<>(Arrays.asList(1, 2));
    SetUtils.SetView<Integer> result = SetUtils.difference(a, b);
    assertTrue(result.size() == 1 && result.contains(5));
}
 
Example 3
Source File: SetUtilsUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenTwoSets_whenUnion_thenUnionResult() {
    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, 5));
    SetUtils.SetView<Integer> union = SetUtils.union(a, b);
    assertTrue(SetUtils.isEqualSet(expected, union));
}
 
Example 4
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 5
Source File: SetUtilsUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenTwoSet_whenDisjunction_thenDisjunctionSet() {
    Set<Integer> a = new HashSet<>(Arrays.asList(1, 2, 5));
    Set<Integer> b = new HashSet<>(Arrays.asList(1, 2, 3));
    SetUtils.SetView<Integer> result = SetUtils.disjunction(a, b);
    assertTrue(result.toSet().contains(5) && result.toSet().contains(3));
}
 
Example 6
Source File: SysRolePermissionService.java    From spring-boot-plus with Apache License 2.0 2 votes vote down vote up
/**
 * 批量保存角色权限关系
 *
 * @param roleId
 * @param addSet
 * @return
 * @throws Exception
 */
boolean saveSysRolePermissionBatch(Long roleId, SetUtils.SetView addSet) throws Exception;