List of usage examples for java.util Set add
boolean add(E e);
From source file:io.cloudslang.lang.cli.SlangBootstrap.java
private static Set<String> findPropertyReferences(String value) { Matcher mather = SUBSTITUTION_PATTERN.matcher(value); Set<String> variableNames = new HashSet<>(); while (mather.find()) { variableNames.add(mather.group(1)); }// www. j a va2s. c o m return variableNames; }
From source file:Main.java
public static <T> Collection<T> union(Collection<T> a, Collection<T> b) { Set<T> set = new HashSet<T>(a); for (T obj : b) { if (!set.contains(obj)) { set.add(obj); }/*from w ww .j a v a 2 s . co m*/ } return set; }
From source file:Main.java
public static Set toSet(Object[] someElements) { Set asSet = new HashSet(someElements.length); for (int i = 0; i < someElements.length; i++) asSet.add(someElements[i]); return asSet; }
From source file:Main.java
public static Set toSet(List someElements) { Set asSet = new HashSet(someElements.size()); for (int i = 0; i < someElements.size(); i++) asSet.add(someElements.get(i)); return asSet; }
From source file:Main.java
private static void addInterfaces(Set<Class<?>> types, Class<?>[] interfaces) { for (Class<?> interfaceClass : interfaces) { types.add(interfaceClass); addInterfaces(types, interfaceClass.getInterfaces()); }/*from w w w . jav a2 s.c o m*/ }
From source file:Main.java
public static <E> Set<E> toSet(Iterable<E> iterable) { if (iterable instanceof Set) { return (Set<E>) iterable; }//from www . j a va 2 s .c om Set<E> set = new HashSet<>(); if (iterable != null) { for (E e : iterable) { set.add(e); } } return set; }
From source file:zipkin.sparkstreaming.job.ZipkinSparkStreamingConfiguration.java
/** * This assumes everything is in the uber-jar except perhaps the adjusters (which are themselves * self-contained jars)./* w w w. j a v a 2 s . co m*/ */ static List<String> pathToJars(Class<?> entryPoint, List<Adjuster> adjusters) { Set<String> jars = new LinkedHashSet<>(); jars.add(pathToJar(entryPoint)); for (Adjuster adjuster : adjusters) { jars.add(pathToJar(adjuster.getClass())); } jars.remove(null); return jars.isEmpty() ? null : new ArrayList<>(jars); }
From source file:com.redhat.red.build.koji.model.json.util.Verifications.java
public static void checkNull(Object value, Set<String> missing, String format, Object... params) { if (value == null) { missing.add(String.format(format, params)); }//from w ww. j av a 2 s .c om }
From source file:com.redhat.red.build.koji.model.json.util.Verifications.java
public static void checkString(String value, Set<String> missing, String format, Object... params) { if (isEmpty(value)) { missing.add(String.format(format, params)); }/*from www . j a v a2 s . com*/ }
From source file:ClassUtil.java
/** * Builds an <b>unordered</b> set of all interface and object classes that * are generalizations of the provided class. * @param classObject the class to find generalization of. * @return a Set of class objects.//from ww w . j ava2 s. co m */ public static Set getGeneralizations(Class classObject) { Set generalizations = new HashSet(); generalizations.add(classObject); Class superClass = classObject.getSuperclass(); if (superClass != null) { generalizations.addAll(getGeneralizations(superClass)); } Class[] superInterfaces = classObject.getInterfaces(); for (int i = 0; i < superInterfaces.length; i++) { Class superInterface = superInterfaces[i]; generalizations.addAll(getGeneralizations(superInterface)); } return generalizations; }