List of usage examples for java.util Set add
boolean add(E e);
From source file:Main.java
private static Set<String> filter(final List<String> enabledCiphers, final Set<String> supportedCiphers) { Set<String> result = new LinkedHashSet<String>(); for (String enabledCipher : enabledCiphers) { if (supportedCiphers.contains(enabledCipher)) { result.add(enabledCipher); }//from w w w. j av a2 s.c o m } return result; }
From source file:ch.systemsx.cisd.openbis.generic.shared.translator.VocabularyTermTranslator.java
public static Set<VocabularyTerm> translateTerms(Set<VocabularyTermPE> terms) { final Set<VocabularyTerm> result = new HashSet<VocabularyTerm>(); for (VocabularyTermPE term : terms) { result.add(translate(term)); }/* www . j a va 2s . c o m*/ return result; }
From source file:edu.harvard.med.screensaver.util.CollectionUtils.java
@SuppressWarnings("unchecked") public static <I> Set<I> entityIds(Collection<? extends Entity> entities) { Set<I> ids = new HashSet<I>(entities.size()); for (Entity entity : entities) { ids.add((I) entity.getEntityId()); }//from w ww . ja v a2 s . c o m return ids; }
From source file:io.v.syncbase.core.Permissions.java
private static Set<String> parseBlessingPatternList(JSONArray jsonArray) throws JSONException { Set<String> blessings = new HashSet<>(); for (int i = 0; i < jsonArray.length(); i++) { blessings.add(jsonArray.getString(i)); }//from w w w . j a va 2 s .c o m return blessings; }
From source file:Main.java
public static <T> Set<T> intersection(Collection<? extends T> c1, Collection<? extends T> c2) { Set<T> result = new HashSet<T>(); for (Iterator<? extends T> it = c1.iterator(); it.hasNext();) { T element = it.next();/* ww w. java2s . c o m*/ if (c2.contains(element)) result.add(element); } return result; }
From source file:Main.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public static List removeDuplicate(List list) { Set set = new HashSet(); List newList = new ArrayList(); for (Iterator iter = list.iterator(); iter.hasNext();) { Object element = iter.next(); if (set.add(element)) newList.add(element);//from w ww .j a v a 2 s .c o m } // list.addAll(newList); return newList; }
From source file:com.vmware.photon.controller.api.frontend.lib.UsageTagHelper.java
public static Set<String> deserializeToStringSet(String concatenatedUsageTags) { Set<String> usageTags = new HashSet<>(); for (UsageTag usageTag : deserialize(concatenatedUsageTags)) { usageTags.add(usageTag.toString()); }/*from w w w.j a va 2s . co m*/ return usageTags; }
From source file:Main.java
public static final Set<String> stringArrayToSet(final String[] array) { if (array == null) { return Collections.emptySet(); }/*from ww w . j a va 2s . com*/ Set<String> tmp = new LinkedHashSet<>(); for (String part : array) { String trimmed = part.trim(); if (trimmed.length() > 0) { tmp.add(trimmed.intern()); } } return tmp; }
From source file:net.sf.beanlib.CollectionPropertyName.java
/** Convenient factory method. */ public static <T> CollectionPropertyName<T>[] createCollectionPropertyNames(Class<T> declaringClass, String[] collectionProperties) { Set<CollectionPropertyName<T>> set = new HashSet<CollectionPropertyName<T>>(); for (String s : collectionProperties) set.add(new CollectionPropertyName<T>(declaringClass, s)); @SuppressWarnings("unchecked") CollectionPropertyName<T>[] ret = (CollectionPropertyName<T>[]) set.toArray(EMPTY_ARRAY); return ret;//from w w w .j a v a 2s . c om }
From source file:grails.plugin.searchable.internal.support.DynamicMethodUtils.java
/** * Extract the property names from the given method name suffix * * @param methodSuffix a method name suffix like 'NameAndAddress' * @return a Collection of property names like ['name', 'address'] *//*from w w w .ja v a 2s . c o m*/ public static Collection extractPropertyNames(String methodSuffix) { String[] splited = methodSuffix.split("And"); Set propertyNames = new HashSet(); for (int i = 0; i < splited.length; i++) { if (splited[i].length() > 0) { propertyNames.add(Introspector.decapitalize(splited[i])); } } return propertyNames; }