List of usage examples for java.util Set add
boolean add(E e);
From source file:com.siemens.sw360.datahandler.common.JacksonUtils.java
public static Set<String> extractSet(ArrayNode array) throws SW360Exception { Set<String> result = new HashSet<>(); for (JsonNode jsonNode : array) { if (jsonNode.isTextual()) result.add(jsonNode.textValue()); else//ww w . jav a 2 s . com throw new SW360Exception("Non textual string ?!"); } return result; }
From source file:Main.java
public static Set getAllRunningService(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> infos = activityManager.getRunningServices(0x7FFFFFFF); Set<String> names = new HashSet<>(); if (infos == null || infos.size() == 0) return null; for (RunningServiceInfo info : infos) { names.add(info.service.getClassName()); }/*www .j a v a 2 s . c o m*/ return names; }
From source file:Main.java
/** * Bestimmt die Schnittmenge zweier Mengen. * //ww w . j av a 2 s . c o m * @param <T> * der Typ der Mengen. * @param set1 * die erste Menge. * @param set2 * die zweite Menge. * @return die Schnittmenge. */ public static <T> Set<T> intersection(final Set<T> set1, final Set<T> set2) { final Set<T> result = new HashSet<T>(); for (final T e : set1) { if (set2.contains(e)) { result.add(e); } } return result; }
From source file:com.optimalbi.Services.Service.java
/** * A set of titles that mean the service is currently in a state that incurs cost *///from ww w. j ava 2 s . com public static Set<String> runningTitles() { Set<String> runningTitles = new HashSet<>(); runningTitles.add("running"); runningTitles.add("available"); runningTitles.add("creating"); runningTitles.add("active"); return runningTitles; }
From source file:Main.java
public static <T> Set<T> newHashSet(final T... ts) { final Set<T> resultSet = new HashSet<T>(); if (ts == null) { return new HashSet<T>(); } else {//w w w . j av a 2 s . com for (final T t : ts) { resultSet.add(t); } } return resultSet; }
From source file:Main.java
/** * @param orig//from w w w .j a v a 2s. c om * if null, return intersect */ public static Set<? extends Object> intersectSet(Set<? extends Object> orig, Set<? extends Object> intersect) { if (orig == null) return intersect; if (intersect == null || orig.isEmpty()) return Collections.emptySet(); Set<Object> set = new HashSet<Object>(orig.size()); for (Object p : orig) { if (intersect.contains(p)) set.add(p); } return set; }
From source file:com.enonic.cms.core.content.contenttype.ContentTypeKey.java
public static Set<ContentTypeKey> convertToSet(int[] array) throws InvalidKeyException { if ((array == null) || (array.length == 0)) { return null; }//from ww w . j a va 2 s.c om Set<ContentTypeKey> set = new HashSet<ContentTypeKey>(array.length); for (int value : array) { set.add(new ContentTypeKey(value)); } return set; }
From source file:fr.mby.portal.coreimpl.acl.AclHelper.java
public static Set<IRole> buileRoleSet(final IRole... roles) { Assert.notNull(roles, "No roles supplied !"); final Set<IRole> set = new HashSet<IRole>(roles.length); for (final IRole role : roles) { if (role != null) { set.add(role); }/* w w w .ja va2s . c om*/ } return set; }
From source file:com.civprod.writerstoolbox.NaturalLanguage.util.RegexStringTokenizer.java
public static Set<Pattern> getRemovePatterns() { Set<Pattern> rList = new HashSet<>(1); rList.add(WhiteSpacePattern); return rList; }
From source file:Main.java
@SuppressWarnings("unchecked") public static boolean addToSetInMap(Object key, Object value, Map theMap) { if (theMap == null) return false; Set theSet = (Set) theMap.get(key); if (theSet == null) { theSet = new LinkedHashSet(); theMap.put(key, theSet);// w w w. j av a2s.c om } return theSet.add(value); }