List of usage examples for java.util Set add
boolean add(E e);
From source file:ch.systemsx.cisd.openbis.generic.server.business.bo.common.EntityListingTestUtils.java
private static <T extends IIdHolder> Set<Long> extractIds(List<T> items) { Set<Long> ids = new HashSet<Long>(); for (T item : items) { ids.add(item.getId()); }// w w w . ja v a2s . c om return ids; }
From source file:br.usp.poli.lta.cereda.aa.utils.SetOperations.java
/** * Calcula o produto cartesiano de um vetor de conjuntos. * @param sets Vetor de conjuntos./*from w ww . j a va 2 s . c o m*/ * @return Produto cartesiano do vetor de conjuntos. */ public static Set<List<Object>> cartesianProduct(Set<?>... sets) { // deve haver mais do que um conjunto Validate.isTrue(sets.length > 1, "No possvel calcular o produto cartesiano " + "de apenas um conjunto."); // nenhum conjunto pode ser vazio for (Set<?> set : sets) { Validate.isTrue(!set.isEmpty(), "No possvel calcular o produto cartesiano " + "quando um dos conjuntos vazio."); } // calcula o produto cartesiano Set<List<Object>> elements = fetchElements(0, sets); // o retorno da funo gera listas com elementos em ordem // reversa, portanto, necessrio inverter os elementos das // listas obtidas Set<List<Object>> result = new HashSet<>(); for (List<Object> list : elements) { Collections.reverse(list); result.add(list); } return result; }
From source file:com.acc.storefront.util.MetaSanitizerUtil.java
/** * Takes a List of KeywordModels and returns a comma separated list of keywords as String. * // www . j av a2 s. c o m * @param keywords * List of KeywordModel objects * @return String of comma separated keywords */ public static String sanitizeKeywords(final List<KeywordModel> keywords) { if (keywords != null && !keywords.isEmpty()) { // Remove duplicates final Set<String> keywordSet = new HashSet<String>(keywords.size()); for (final KeywordModel keyword : keywords) { keywordSet.add(keyword.getKeyword()); } // Format keywords, join with comma final StringBuilder stringBuilder = new StringBuilder(); for (final String keyword : keywordSet) { stringBuilder.append(keyword).append(','); } if (stringBuilder.length() > 0) { // Remove last comma return stringBuilder.substring(0, stringBuilder.length() - 1); } } return ""; }
From source file:com.myGengo.alfresco.utils.MyGengoUtils.java
public static NodeRef getCommentsFolder(NodeRef nodeRef, NodeService nodeService) { NodeRef commentsFolder = null;/*from w ww .j a v a2 s.com*/ Set<QName> types = new HashSet<QName>(1, 1.0f); types.add(ForumModel.TYPE_FORUM); List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(nodeRef, types); if (childAssocs.size() > 0) { NodeRef discussionFolder = childAssocs.get(0).getChildRef(); commentsFolder = nodeService.getChildByName(discussionFolder, ContentModel.ASSOC_CONTAINS, COMMENTS_TOPIC_NAME); } return commentsFolder; }
From source file:com.haulmont.cuba.gui.components.filter.UserSetHelper.java
public static String createIdsString(Set<String> current, Collection entities) { Set<String> convertedSet = new HashSet<>(); for (Object entity : entities) { convertedSet.add(((BaseUuidEntity) entity).getId().toString()); }//w w w .j a va 2 s . c o m current.addAll(convertedSet); if (current.isEmpty()) { return "NULL"; } StringBuilder listOfId = new StringBuilder(); Iterator it = current.iterator(); while (it.hasNext()) { listOfId.append(it.next()); if (it.hasNext()) { listOfId.append(','); } } return listOfId.toString(); }
From source file:com.haulmont.cuba.gui.components.filter.UserSetHelper.java
public static String removeIds(Set<String> current, Collection entities) { Set<String> convertedSet = new HashSet<>(); for (Object entity : entities) { convertedSet.add(((BaseUuidEntity) entity).getId().toString()); }/*from ww w. ja v a 2 s. com*/ current.removeAll(convertedSet); if (current.isEmpty()) { return "NULL"; } StringBuilder listOfId = new StringBuilder(); Iterator it = current.iterator(); while (it.hasNext()) { listOfId.append(it.next()); if (it.hasNext()) { listOfId.append(','); } } return listOfId.toString(); }
From source file:org.devgateway.toolkit.persistence.spring.CustomJPAUserDetailsService.java
/** * Reads {@link PersistedAuthority} objects from the * {@link org.devgateway.eudevfin.auth.common.domain.PersistedUser#getPersistedAuthorities()} * and also from the {@link PersistedUserGroup#getPersistedAuthorities()} * (only if the {@link User} belongs to only one {@link PersistedUserGroup}) * and converts all {@link PersistedAuthority} objects to * {@link GrantedAuthority}./* ww w .j av a 2 s. c o m*/ * * @param domainUser * @return a {@link Set} containing the {@link GrantedAuthority}S */ public static Set<GrantedAuthority> getGrantedAuthorities(final Person domainUser) { Set<GrantedAuthority> grantedAuth = new HashSet<GrantedAuthority>(); // get user authorities for (Role authority : domainUser.getRoles()) { grantedAuth.add(new SimpleGrantedAuthority(authority.getAuthority())); } return grantedAuth; }
From source file:com.gargoylesoftware.htmlunit.gae.GAETestRunner.java
/** * Get list of classes that are not being used * but are loaded by getHtmlJavaScriptMapping() in * {@link com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration} * * @return the list of additional classes. *//*ww w . j a v a2 s . com*/ private static Set<String> getAdditionalWhitelist() { final String[] additionalClasses = { "java.awt.image.RenderedImage", "java.awt.geom.Rectangle2D", "java.awt.geom.Ellipse2D", "java.applet.AppletStub" }; final Set<String> classesAsSet = new HashSet<>(); for (String additionalClass : additionalClasses) { classesAsSet.add(additionalClass); } return classesAsSet; }
From source file:edu.umass.cs.gigapaxos.PaxosServer.java
private static Set<String> processArgs(String[] args, NodeConfig<String> nodeConfig) { // -c options => start with clean DB for (String arg : args) if (arg.trim().equals("-c")) PaxosManager.startWithCleanDB(true); // server names must be at the end of args Set<String> servers = new HashSet<String>(); for (int i = args.length - 1; i >= 0; i--) if (nodeConfig.nodeExists(args[i])) servers.add(args[i]); return servers; }
From source file:fr.esiea.windmeal.fill.database.OwnerAndProviderImportationTest.java
private static Set<Tag> getTagsFromMap(Map<String, String> dataMap) { int acc = 1;//from ww w . jav a 2s. co m Set<Tag> tags = new HashSet<Tag>(); while (dataMap.containsKey("tag" + acc)) { tags.add(Tag.valueOf(dataMap.get("tag" + acc))); acc++; } return tags; }