List of usage examples for java.util Set add
boolean add(E e);
From source file:Main.java
protected static Set intersectEmail(Set permitted, String email) { String _sub = email.substring(email.indexOf('@') + 1); if (permitted.isEmpty()) { permitted.add(_sub); return permitted; } else {//w ww. j a v a 2 s. c o m Set intersect = new HashSet(); Iterator _iter = permitted.iterator(); while (_iter.hasNext()) { String _permitted = (String) _iter.next(); if (_sub.endsWith(_permitted)) { intersect.add(_sub); } else if (_permitted.endsWith(_sub)) { intersect.add(_permitted); } } return intersect; } }
From source file:net.sourceforge.vulcan.jabber.JdbcScreenNameMapperTest.java
static Iterable<Committer> makeAuthorList(String... names) { Set<Committer> list = new HashSet<Committer>(); for (String name : names) { list.add(new Committer(name, null)); }/* ww w . ja v a 2 s . c o m*/ return list; }
From source file:com.citytechinc.cq.clientlibs.api.util.ComponentUtils.java
public static Set<Resource> flattenResourceTree(Resource root, boolean inclusive) { Iterator<Resource> typedResourceIterator = root.getResourceResolver() .findResources(TYPED_COMPONENT_QUERY.replace("{path}", root.getPath()), Query.JCR_SQL2); Set<Resource> flattenedResourceTree = Sets.newHashSet(typedResourceIterator); if (inclusive) { flattenedResourceTree.add(root); }/*from ww w .j a v a2 s . c o m*/ return flattenedResourceTree; }
From source file:Main.java
public static <K, V> Map<K, V> valueSortedMap(Map<K, V> map, Comparator<Entry<K, V>> comparator) { Set<Entry<K, V>> valueSortedEntries = new TreeSet<Entry<K, V>>(comparator); for (Entry<K, V> entry : map.entrySet()) { valueSortedEntries.add(entry); }/*from www. ja v a 2 s. c o m*/ Map<K, V> sortedMap = new LinkedHashMap<K, V>(map.size()); for (Entry<K, V> entry : valueSortedEntries) { sortedMap.put(entry.getKey(), entry.getValue()); } return sortedMap; }
From source file:Main.java
protected static Set unionEmail(Set excluded, String email) { String _sub = email.substring(email.indexOf('@') + 1); if (excluded.isEmpty()) { excluded.add(_sub); return excluded; } else {//w w w . j a va2s . com Set intersect = new HashSet(); Iterator _iter = excluded.iterator(); while (_iter.hasNext()) { String _excluded = (String) _iter.next(); if (_sub.endsWith(_excluded)) { intersect.add(_excluded); } else if (_excluded.endsWith(_sub)) { intersect.add(_sub); } else { intersect.add(_excluded); intersect.add(_sub); } } return intersect; } }
From source file:com.google.api.services.samples.calendar.cmdline.CalendarSample.java
/** Authorizes the installed application to access user's protected data. */ private static Credential authorize() throws Exception { // load client secrets GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(CalendarSample.class.getResourceAsStream("/client_secrets.json"))); if (clientSecrets.getDetails().getClientId().startsWith("Enter") || clientSecrets.getDetails().getClientSecret().startsWith("Enter ")) { System.out.println(/* w ww.j av a 2s. co m*/ "Overwrite the src/main/resources/client_secrets.json file with the client secrets file " + "you downloaded from the Quickstart tool or manually enter your Client ID and Secret " + "from https://code.google.com/apis/console/?api=calendar#project:319518489594 " + "into src/main/resources/client_secrets.json"); System.exit(1); } // Set up authorization code flow. // Ask for only the permissions you need. Asking for more permissions // will // reduce the number of users who finish the process for giving you // access // to their accounts. It will also increase the amount of effort you // will // have to spend explaining to users what you are doing with their data. // Here we are listing all of the available scopes. You should remove // scopes // that you are not actually using. Set<String> scopes = new HashSet<String>(); scopes.add(CalendarScopes.CALENDAR); scopes.add(CalendarScopes.CALENDAR_READONLY); GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(httpTransport, JSON_FACTORY, clientSecrets, scopes).setDataStoreFactory(dataStoreFactory).build(); // authorize return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user"); }
From source file:Main.java
/** * Select the given number of elements from the given set. * * @param <T> encapsulated type/*from w w w .j a va 2s .co m*/ * @param set set * @param count number of elements to retrieve * @return set */ public static <T> Set<T> selectSome(Set<T> set, int count) { Set<T> newSet = new HashSet<T>(); int i = 0; for (T each : set) { if (++i > count) { break; } newSet.add(each); } return newSet; }
From source file:br.usp.poli.lta.cereda.aa.utils.SetOperations.java
/** * Obtm, de forma recursiva, o produto cartesiano de um vetor de conjuntos * de acordo com o ndice fornecido, em ordem reversa. * @param index ?ndice fornecido.//from w w w . ja va 2 s . co m * @param sets Vetor de conjuntos. * @return Produto cartesiano do vetor de conjuntos de acordo com o ndice * fornecido, em ordem reversa. */ private static Set<List<Object>> fetchElements(int index, Set<?>... sets) { Set<List<Object>> result = new HashSet<>(); if (index == sets.length) { result.add(new ArrayList<>()); } else { for (Object obj : sets[index]) { for (List<Object> set : fetchElements(index + 1, sets)) { set.add(obj); result.add(set); } } } return result; }
From source file:com.glweb.module.forum.JUnitForumHelper.java
public static Set buildModerators() { Set _moderators = new HashSet(); _moderators.add(JUnitForumHelper.getPosterPaxson()); _moderators.add(JUnitForumHelper.getPosterCat()); return _moderators; }
From source file:Main.java
private static void createSetOfFields(Set<Field> collectionFields, Class c) { Field[] fields = c.getDeclaredFields(); for (Field f : fields) { collectionFields.add(f); }/*from w ww . ja v a 2 s . co m*/ }