List of usage examples for java.util Set add
boolean add(E e);
From source file:com.zotoh.maedr.impl.DefaultDeviceFactory.java
/** * @return//from w w w.j av a 2s. com */ public static Set<String> getAllDefaultTypes() { Set<String> rc = ST(); rc.add(DT_WEB_SERVLET); for (int i = 0; i < DEVS.length; ++i) { rc.add(DEVS[i]); } return rc; }
From source file:Main.java
public static <T> Set<T> extractIntersection(Set<T> left, Set<T> right) { Set<T> intersection = new HashSet<>(); for (T itemLeft : left) { for (T itemRight : right) { if (itemLeft.equals(itemRight)) { intersection.add(itemLeft); }/* w w w. j a va 2 s. c o m*/ } } return intersection; }
From source file:SetUtils.java
public static Set intersection(Set a, Set b) { Set c = new HashSet(); for (Iterator iter = b.iterator(); iter.hasNext();) { Object e = iter.next();//w w w . j a v a 2 s. c o m if (a.contains(e)) { c.add(e); } } return c; }
From source file:ch.ifocusit.plantuml.utils.ClassUtils.java
public static Set<Class> getConcernedTypes(Field field) { Set<Class> classes = new HashSet<>(); classes.add(field.getType()); classes.addAll(getGenericTypes(field)); return classes; }
From source file:ch.ifocusit.plantuml.utils.ClassUtils.java
public static Set<Class> getConcernedTypes(Parameter parameter) { Set<Class> classes = new HashSet<>(); classes.add(parameter.getType()); classes.addAll(getGenericTypes(parameter)); return classes; }
From source file:com.vmware.identity.openidconnect.server.ClientInfoRetriever.java
private static Set<URI> uriSetFromStringList(List<String> stringList) throws ServerException { Set<URI> uriSet = new HashSet<URI>(); if (stringList != null) { for (String s : stringList) { uriSet.add(uriFromString(s)); }//w ww.j a v a 2 s . com } return uriSet; }
From source file:Main.java
/** * Converts the given array to a set with the given type. Works like * {@link Arrays#asList(Object...)}.//from ww w . j a v a2 s.c o m * * @param <T> * The type of the set values. * @param setType * The set type to return. * @param arr * The array to convert into a set. * @return An object of the given set or, if, and only if, an error * occurred, <code>null</code>. */ @SuppressWarnings("unchecked") public static <T> Set<T> toSet(@SuppressWarnings("rawtypes") final Class<? extends Set> setType, final T... arr) { assert setType != null : "SetType cannot be null!"; assert !Modifier.isAbstract(setType.getModifiers()) : "SetType cannot be abstract!"; assert !setType.isInterface() : "SetType cannot be an interface!"; assert arr != null : "Arr cannot be null!"; Set<T> result = null; try { result = setType.newInstance(); for (final T t : arr) { result.add(t); } } catch (final InstantiationException ex) { ex.printStackTrace(); } catch (final IllegalAccessException ex) { ex.printStackTrace(); } return result; }
From source file:Main.java
public static <T> Set<Class<? extends T>> filter(Collection<Class<? extends T>> source, String packageFilter) { Set<Class<? extends T>> filtered = new HashSet<Class<? extends T>>(); for (Class<? extends T> klazz : source) { if (klazz.getName().startsWith(packageFilter)) filtered.add(klazz); }//from w ww . j a v a 2 s . co m return filtered; }
From source file:Main.java
/** * Reads the data from the {@code column} of the content's {@code queryUri} and returns it as an * Array./*from w ww . ja v a 2s. c o m*/ */ static private Set<String> getColumnContentAsArray(Context context, Uri queryUri, String column) { Cursor cursor = context.getContentResolver().query(queryUri, new String[] { column }, null, null, null); Set<String> columnValues = new HashSet<>(); try { if (cursor != null && cursor.moveToFirst()) { do { columnValues.add(cursor.getString(0)); } while (cursor.moveToNext()); } } finally { if (cursor != null) { cursor.close(); } } return columnValues; }
From source file:com.intuit.autumn.web.WebServices.java
private static void loadIfEnabled(final Properties properties, Set<Class<? extends Service>> services, final String key) { if (toBoolean(getProperty(key, properties))) { services.add(WEB_SERVICES.get(key)); }/*from w w w .j a v a2s . c o m*/ }