Example usage for com.google.common.collect Sets newHashSet

List of usage examples for com.google.common.collect Sets newHashSet

Introduction

In this page you can find the example usage for com.google.common.collect Sets newHashSet.

Prototype

public static <E> HashSet<E> newHashSet() 

Source Link

Document

Creates a mutable, initially empty HashSet instance.

Usage

From source file:presto.android.MultiMapUtil.java

public static <Key, HashSetElement, SubClassOfHashSetElement extends HashSetElement> void addKeyAndHashSetElement(
        Map<Key, Set<HashSetElement>> map, Key key, SubClassOfHashSetElement element) {
    Set<HashSetElement> set = map.get(key);
    if (set == null) {
        set = Sets.newHashSet();
        map.put(key, set);/*ww w  .  j a v a  2  s . c o  m*/
    }
    set.add(element);
}

From source file:de.doering.dwca.flickr.FlickrImage.java

public static Set<String> getTagMappings(ConceptTerm term) {
    Set<String> tags = Sets.newHashSet();
    for (String t : TAG_MAPPING.keySet()) {
        if (term.equals(TAG_MAPPING.get(t))) {
            tags.add(t);// w w w.  j a  v a2 s.  c o m
        }
    }
    return tags;
}

From source file:apm.common.utils.excel.fieldtype.RoleListType.java

/**
 * ?/*w  w  w . ja v a2s . c o m*/
 */
public static Object getValue(String val) {
    Set<Role> roleList = Sets.newHashSet();
    List<Role> allRoleList = roleService.findAllRole();
    for (String s : StringUtils.split(val, ",")) {
        for (Role e : allRoleList) {
            if (e.getName().equals(s)) {
                roleList.add(e);
            }
        }
    }
    return roleList.size() > 0 ? roleList : null;
}

From source file:org.gradle.language.base.internal.model.VariantsMetaDataHelper.java

public static Set<String> determineAxesWithIncompatibleTypes(VariantsMetaData reference,
        VariantsMetaData candidate, Set<String> testedDimensions) {
    Set<String> result = Sets.newHashSet();
    for (String commonDimension : testedDimensions) {
        ModelType<?> resolveType = reference.getVariantAxisType(commonDimension);
        ModelType<?> binaryVariantType = candidate.getVariantAxisType(commonDimension);
        if (binaryVariantType != null && !resolveType.isAssignableFrom(binaryVariantType)) {
            result.add(commonDimension);
        }/*from  w  w  w  .j a va 2s  .c o  m*/
    }
    return result;
}

From source file:org.robobinding.viewattribute.listview.SparseBooleanArrayUtils.java

public static Set<Integer> toSet(SparseBooleanArray array) {
    Set<Integer> trueSet = Sets.newHashSet();
    for (int i = 0; i < array.size(); i++) {
        if (array.valueAt(i)) {
            int position = array.keyAt(i);
            trueSet.add(position);//from ww w  . ja v a  2  s.  c  om
        }
    }
    return trueSet;
}

From source file:com.googlecode.t7mp.util.FileUtil.java

public static Set<File> getAllFiles(File rootDirectory) {
    Set<File> fileSet = Sets.newHashSet();
    return getAllFiles(rootDirectory, fileSet);
}

From source file:org.jetbrains.jet.buildergen.entities.EntityUtil.java

@NotNull
public static Collection<Relation<?>> getAllRelations(@NotNull Entity entity) {
    Collection<Relation<?>> result = Lists.newArrayList();
    Set<Relation<?>> visited = Sets.newHashSet();
    collectAllRelations(entity, result, visited);
    return result;
}

From source file:software.uncharted.model.ImageSearchResult.java

public static ImageSearchResult empty() {
    return new ImageSearchResult().setImages(Sets.newHashSet()).setDuration(0L);
}

From source file:com.topekalabs.algos.discrete.Permutations.java

public static <L, V> Set<Map<L, V>> labeledPermutations(Map<L, Set<V>> valuesMap) {
    Set<Map<L, V>> permutations = Sets.newHashSet();

    if (valuesMap.isEmpty()) {
        return permutations;
    }//from w ww. j a va2  s  . c  o m

    Map.Entry<L, Set<V>> mapEntry = CollectionUtils.getSingleElement(valuesMap.entrySet());
    L label = mapEntry.getKey();
    Set<V> values = mapEntry.getValue();

    if (valuesMap.size() == 1) {
        for (V value : values) {
            Map<L, V> permutation = Maps.newHashMap();
            permutation.put(label, value);
            permutations.add(permutation);
        }

        return permutations;
    }

    Map<L, Set<V>> reducedValuesMap = Maps.newHashMap(valuesMap);
    reducedValuesMap.remove(label);

    Set<Map<L, V>> reducedPermutations = labeledPermutations(reducedValuesMap);

    for (Map<L, V> reducedPermutation : reducedPermutations) {
        for (V value : values) {
            Map<L, V> permutation = Maps.newHashMap(reducedPermutation);
            permutation.put(label, value);
            permutations.add(permutation);
        }
    }

    return permutations;
}

From source file:com.topekalabs.collection.utils.ListUtils.java

public static <T> void listContainsDuplicateReferencesException(List<T> list) {
    Set<ReferenceWrapper<T>> elementSet = Sets.newHashSet();

    for (T element : list) {
        elementSet.add(new ReferenceWrapper<>(element));
    }//from w ww  . j a  va 2s  .  co  m

    if (elementSet.size() != list.size()) {
        throw new IllegalArgumentException("The given list contains duplicate references.");
    }
}