List of usage examples for java.util Collections singleton
public static <T> Set<T> singleton(T o)
From source file:Main.java
public static <E extends Object> void removeNullFromList(List<E> list) { list.removeAll(Collections.singleton(null)); }
From source file:Main.java
public static Set getSet(Object... objs) { if (objs.length == 0) { return Collections.emptySet(); } else if (objs.length == 1) { return Collections.singleton(objs[0]); } else {/*from w w w .j a v a2 s.com*/ return new HashSet(Arrays.asList(objs)); } }
From source file:Main.java
public static <E> Set<E> asSet(E... elements) { if (elements == null || elements.length == 0) { return Collections.emptySet(); }//w w w.jav a2s . c o m if (elements.length == 1) { return Collections.singleton(elements[0]); } LinkedHashSet<E> set = new LinkedHashSet<E>(elements.length * 4 / 3 + 1); Collections.addAll(set, elements); return set; }
From source file:com.vmware.identity.openidconnect.common.ResponseType.java
public static ResponseType authorizationCode() { return new ResponseType(Collections.singleton(ResponseTypeValue.AUTHORIZATION_CODE)); }
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. *///from www . j a v a2 s . c om 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 ww . j a v a2s. co 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:cc.kave.commons.model.groum.SubGroum.java
public static SubGroumMultiSet getAtomicSubGroums(Groum groum) { SubGroumMultiSet atomics = new SubGroumMultiSet(); for (Node node : groum.getAllNodes()) { Set<Node> nodes = Collections.singleton(node); SubGroum subGroum = new SubGroum(groum, nodes); atomics.add(subGroum);//from www . j av a2 s. c o m } return atomics; }
From source file:com.vmware.identity.openidconnect.common.ResponseType.java
public static ResponseType idToken() { return new ResponseType(Collections.singleton(ResponseTypeValue.ID_TOKEN)); }
From source file:com.mirth.connect.donkey.server.data.ChannelDoesNotExistException.java
public ChannelDoesNotExistException(String channelId) { this(Collections.singleton(channelId)); }
From source file:com.hubrick.raml.mojo.util.RamlUtil.java
public static String toJavaMethodName(Action action) { final List<String> nameElements = stream(spliterator(action.getResource().getUri().split("\\/")), false) .filter(path -> !path.matches(".*\\{[^\\}]*\\}.*")) .map(path -> stream(spliterator(path.split("(?i:[^a-z0-9])")), false).map(StringUtils::capitalize) .collect(toList()))//from ww w . j a va 2 s . c o m .flatMap(tokens -> tokens.stream()).collect(toList()); return Joiner.on("") .join(Iterables.concat(Collections.singleton(action.getType().name().toLowerCase()), nameElements)); }