List of usage examples for java.util Collections unmodifiableSet
public static <T> Set<T> unmodifiableSet(Set<? extends T> s)
From source file:Main.java
/** * Convert a char array to a unmodifiable Set. * * @param array the contents of the new Set * @return a unmodifiable Set containing the elements in the array. */// w ww . j a v a2s . c o m public static Set<Character> arrayToUnmodifiableSet(char... array) { if (array == null) { return Collections.emptySet(); } if (array.length == 1) { return Collections.singleton(array[0]); } return Collections.unmodifiableSet(arrayToSet(array)); }
From source file:Main.java
/** * Convert a String to a unmodifiable set of characters. * * @param str The string to convert//from w w w . j a v a 2 s . c o m * @return A set containing the characters in str. A empty set is returned if str is null. */ public static Set<Character> strToUnmodifiableSet(String str) { if (str == null) { return Collections.emptySet(); } if (str.length() == 1) { return Collections.singleton(str.charAt(0)); } return Collections.unmodifiableSet(strToSet(str)); }
From source file:net.openid.appauth.AdditionalParamsProcessor.java
static Set<String> builtInParams(String... params) { if (params == null || params.length == 0) { return Collections.emptySet(); }/*from w w w .j a v a 2 s. co m*/ return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(params))); }
From source file:Main.java
/** * Returns an immutable Serializable Set containing the values. * @param <T> T/* w ww.j a v a 2s . co m*/ * @param values Collection<T> * @return Set<T> */ public static <T> Set<T> unmodifiableSet(Collection<T> values) { TreeSet<T> set = new TreeSet<T>(values); return Collections.unmodifiableSet(set); }
From source file:Main.java
public static Set<String> getQueryParameterNames(Uri uri) { String query = uri.getEncodedQuery(); if (query == null) { return Collections.emptySet(); }//from w w w .j a v a2s. c om Set<String> names = new LinkedHashSet<String>(); int start = 0; do { int next = query.indexOf('&', start); int end = (next == -1) ? query.length() : next; int separator = query.indexOf('=', start); if (separator > end || separator == -1) { separator = end; } String name = query.substring(start, separator); names.add(uri.decode(name)); // Move start to end of name. start = end + 1; } while (start < query.length()); return Collections.unmodifiableSet(names); }
From source file:Main.java
/** * @return an <b>UNMODIFIABLE</b> Set<T> *///from w w w .j a v a 2 s . c om @SafeVarargs public static <T> Set<T> set(T... elements) { return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(elements))); }
From source file:org.jboss.capedwarf.connect.server.HttpHeaders.java
/** * Get headers; read-only./*w w w . j av a 2 s . c o m*/ * * @return the headers */ public static Set<Header> getHeaders() { Set<Header> set = tlh.get(); if (set == null) return Collections.emptySet(); return Collections.unmodifiableSet(set); }
From source file:Main.java
/** * Returns an unmodifiable versions of the Set of Enums. If the contents of the set are known * to be unmodifiable by the caller in any way, the set itself will be retured, otherwise an * unmodifiable copy of the Set will be returned. * @param s Set to get the tamper-proof version of * @return An unmodifiable tamper-proof version of the set *///from w w w . ja v a 2s. co m public static <E extends Enum<E>> Set<E> unmodifiableCopyOfEnumSet(Set<E> s) { Class<? extends Set> copyClass = s.getClass(); if ((_EMPTY_SET == copyClass) || (_SINGLETON_SET == copyClass)) { // these classes are already unmodifiable, so just return return s; } else { return Collections.unmodifiableSet(EnumSet.copyOf(s)); } }
From source file:dumpsection.util.Util.java
public static Set<Integer> stringArrayToUnsignedIntegerSet(String[] src, int radix) { Set<Integer> x = new HashSet<>(); List<String> ls = new ArrayList<>(); ls.addAll(Arrays.asList(src)); for (String s : ls) { try {//from w w w.j av a2 s. c o m x.add(Integer.parseUnsignedInt(s, radix)); } catch (NumberFormatException e) { throw e; } } return Collections.unmodifiableSet(x); }
From source file:com.github.itoshige.testrail.store.CaseStore.java
public Set<CaseStoreKey> getSectionId2Tiltes() { return Collections.unmodifiableSet(casesMap.keySet()); }