Java 类org.apache.commons.collections4.multimap.HashSetValuedHashMap 实例源码

项目:java-cloud-filesystem-provider    文件:CloudFileSystemProviderDelegate.java   
/**
 * Splits a set of paths into a map by their {@link CloudFileSystemImplementation}. This is used for the
 * optimised {@link #delete(Set, EnumSet)}, {@link #delete(Set, DeleteOption...)} operations.
 * @param paths
 * @return
 */
Map<CloudFileSystemImplementation, Collection<CloudPath>> splitPathsByImplementation(Set<CloudPath> paths) {
    HashSetValuedHashMap<CloudFileSystemImplementation,CloudPath> map = new HashSetValuedHashMap<>();

    for (CloudPath path : paths) {
        CloudFileSystemImplementation cloudFileSystemImplementation = getCloudFileSystemImplementation(path);
        map.put(cloudFileSystemImplementation, path);
    }

    return map.asMap();
}
项目:java-cloud-filesystem-provider    文件:DefaultCloudAclEntryConflictCheckerTest.java   
@Test
public void testIterateAcrossAllAclsOnlyIteratesAcrossTwoAclsOnce() throws NotOwnerException {
    CloudAclEntry<?> user1 = createCloudAclEntryMock("user1", UserPrincipal.class);
    CloudAclEntry<?> group1 = createCloudAclEntryMock("group1", GroupPrincipal.class);
    CloudAclEntry<?> group2 = createCloudAclEntryMock("group2", GroupPrincipal.class);
    CloudAclEntry<?> user2 = createCloudAclEntryMock("user2", UserPrincipal.class);
    CloudAclEntry<?> user3 = createCloudAclEntryMock("user3", UserPrincipal.class);
    CloudAclEntry<?> group3 = createCloudAclEntryMock("group3", GroupPrincipal.class);

    CloudAclEntrySet cloudAclEntrySet = new CloudAclEntrySet(AnonymousUserPrincipal.INSTANCE, checker);
    cloudAclEntrySet.addAllEntries(AnonymousUserPrincipal.INSTANCE,
            Arrays.asList(new CloudAclEntry<?>[] {user1, group1, group2, user2, user3, group3}));
    Assert.assertEquals(6, cloudAclEntrySet.size());

    // Get all of the entries into a map. If any cannot be put into the map it means that the two entries
    // have been seen previously.
    HashSetValuedHashMap<CloudAclEntry<?>, CloudAclEntry<?>> map = new HashSetValuedHashMap<>();
    checker.iterateAcrossAllAcls(true, cloudAclEntrySet,
            (entry1 ,entry2) -> {Assert.assertTrue("Two entries in the map have been seen before: " + entry1 + ", " + entry2 + ", map=" + map.toString(),
                                        map.put(entry1, entry2));}
    );

    // Now check the map entries...
    Assert.assertEquals(6, map.size());
    //System.out.println(map.toString());
    HashSetValuedHashMap<Class<?>,CloudAclEntry<?>> cloudAclEntriesByPrincipalClass = new HashSetValuedHashMap<>();
    for (CloudAclEntry<?> key : map.keySet()) {
        cloudAclEntriesByPrincipalClass.put(key.getPrincipalClass(), key);
        Set<CloudAclEntry<?>> values = map.get(key);

        for (CloudAclEntry<?> value : values) {
            cloudAclEntriesByPrincipalClass.put(value.getPrincipalClass(), value);

            // Now check the map entry for this value, the key should not be in this set
            Set<CloudAclEntry<?>> valueEntries = map.get(value);

            // The values may not exist
            if (valueEntries != null) {
                Assert.assertFalse("Two entries in the map have been seen before: " + key + ", " + value + ", map=" + map.toString(),
                    valueEntries.contains(key));
            }
        }
    }

    // Make sure that we have vistited all of the ACL's which we defined in the list
    Assert.assertEquals(3, cloudAclEntriesByPrincipalClass.get(UserPrincipal.class).size());
    Assert.assertEquals(3, cloudAclEntriesByPrincipalClass.get(GroupPrincipal.class).size());
}
项目:onetwo    文件:TemplateImageBuilder.java   
public HashSetValuedHashMap<String, DefinedData<?>> getDefineTables() {
    return defineTables;
}
项目:HCFCore    文件:MultiMapUtils.java   
/**
 * Creates a {@link SetValuedMap} with an {@link java.util.HashSet HashSet} as
 * collection class to store the values mapped to a key.
 *
 * @param <K> the key type
 * @param <V> the value type
 * @return a new {@link SetValuedMap}
 */
public static <K, V> SetValuedMap<K, V> newSetValuedHashMap() {
    return new HashSetValuedHashMap<K, V>();
}
项目:HCFCore    文件:MultiMapUtils.java   
/**
 * Creates a {@link SetValuedMap} with an {@link java.util.HashSet HashSet} as
 * collection class to store the values mapped to a key.
 *
 * @param <K> the key type
 * @param <V> the value type
 * @return a new {@link SetValuedMap}
 */
public static <K, V> SetValuedMap<K, V> newSetValuedHashMap() {
    return new HashSetValuedHashMap<K, V>();
}