List of usage examples for java.util Collection addAll
boolean addAll(Collection<? extends E> c);
From source file:org.openinfinity.core.security.principal.Identity.java
/** * Returns all principals for the user./*ww w . j a va2 s . co m*/ * * @return */ public Collection<Principal> getAllPrincipalsForIdentity() { Collection<Principal> principals = new ArrayList<Principal>(); principals.add(userPrincipal); principals.add(tenantPrincipal); principals.addAll(rolePrincipals); return Collections.unmodifiableCollection(principals); }
From source file:org.training.storefront.breadcrumb.impl.ProductBreadcrumbBuilder.java
public List<Breadcrumb> getBreadcrumbs(final ProductModel productModel) throws IllegalArgumentException { final List<Breadcrumb> breadcrumbs = new ArrayList<>(); final Collection<CategoryModel> categoryModels = new ArrayList<>(); final Breadcrumb last; final ProductModel baseProductModel = getBaseProduct(productModel); last = getProductBreadcrumb(baseProductModel); categoryModels.addAll(baseProductModel.getSupercategories()); last.setLinkClass(LAST_LINK_CLASS);/* w ww . jav a 2s .c om*/ breadcrumbs.add(last); while (!categoryModels.isEmpty()) { CategoryModel toDisplay = null; for (final CategoryModel categoryModel : categoryModels) { if (!(categoryModel instanceof ClassificationClassModel)) { if (toDisplay == null) { toDisplay = categoryModel; } if (getBrowseHistory().findEntryMatchUrlEndsWith(categoryModel.getCode()) != null) { break; } } } categoryModels.clear(); if (toDisplay != null) { breadcrumbs.add(getCategoryBreadcrumb(toDisplay)); categoryModels.addAll(toDisplay.getSupercategories()); } } Collections.reverse(breadcrumbs); return breadcrumbs; }
From source file:model.utilities.ExchangeNetwork.java
/** * At the end of the week the graph is cleared of all edges (unless the good type is labor!!) *//*from w w w . ja v a 2 s .c o m*/ public void weekEnd() { if (!type.isLabor()) { //create a new list Collection<InventoryEdge> edges = new LinkedList<>(); edges.addAll(inventoryGraph.getEdges()); //add all edges to this list //for all inventory edges for (InventoryEdge e : edges) //remove them! //remove! inventoryGraph.removeEdge(e); //repaint so we can see that they disappeared! queueRepaint(); } }
From source file:es.ucm.fdi.dalgs.academicTerm.service.AcademicTermService.java
@PreAuthorize("hasRole('ROLE_USER')") @PostFilter("hasPermission(filterObject, 'READ') or hasPermission(filterObject, 'ADMINISTRATION')") @Transactional(readOnly = true)/* w w w. ja va 2s . c om*/ public ResultClass<AcademicTerm> getAcademicTerm(Long id_academic, Boolean showAll) { ResultClass<AcademicTerm> result = new ResultClass<AcademicTerm>(); AcademicTerm aT = repositoryAcademicTerm.getAcademicTermById(id_academic); if (aT != null) { Collection<Course> courses = new ArrayList<Course>(); courses.addAll(serviceCourse.getCoursesByAcademicTerm(id_academic, showAll)); aT.setCourses(courses); result.setSingleElement(aT); } return result; }
From source file:org.jtheque.movies.services.impl.CategoriesService.java
@Override public Collection<Category> getSubCategories(Category category) { if (category == null) { return CollectionUtils.emptyList(); }/* ww w .ja v a2 s.com*/ Collection<Category> categories = new ArrayList<Category>(20); for (Category cat : getCategories()) { if (cat.getParent() != null && cat.getParent().getId() == category.getId()) { categories.add(cat); categories.addAll(getSubCategories(cat)); } } return categories; }
From source file:com.comcast.video.dawg.service.park.MongoParkService.java
@SuppressWarnings("unchecked") @Override// w w w . j av a 2 s . co m public Collection<String> getAllTags() { Map<String, Object>[] stbs = findAll(); Collection<String> tags = new HashSet<String>(); for (Map<String, Object> stb : stbs) { Collection<String> stbTags = (Collection<String>) stb.get(MetaStb.TAGS); if (stbTags != null) { tags.addAll(stbTags); } } return tags; }
From source file:com.exxonmobile.ace.hybris.storefront.breadcrumb.impl.ProductBreadcrumbBuilder.java
public List<Breadcrumb> getBreadcrumbs(final ProductModel productModel) throws IllegalArgumentException { final List<Breadcrumb> breadcrumbs = new ArrayList<Breadcrumb>(); final Collection<CategoryModel> categoryModels = new ArrayList<CategoryModel>(); final Breadcrumb last; final ProductModel baseProductModel = getBaseProduct(productModel); last = getProductBreadcrumb(baseProductModel); categoryModels.addAll(baseProductModel.getSupercategories()); last.setLinkClass(LAST_LINK_CLASS);// w ww . j ava 2s . c o m breadcrumbs.add(last); while (!categoryModels.isEmpty()) { CategoryModel toDisplay = null; for (final CategoryModel categoryModel : categoryModels) { if (!(categoryModel instanceof ClassificationClassModel)) { if (toDisplay == null) { toDisplay = categoryModel; } if (getBrowseHistory().findUrlInHistory(categoryModel.getCode()) != null) { break; } } } categoryModels.clear(); if (toDisplay != null) { breadcrumbs.add(getCategoryBreadcrumb(toDisplay)); categoryModels.addAll(toDisplay.getSupercategories()); } } Collections.reverse(breadcrumbs); return breadcrumbs; }
From source file:com.netscape.cmstools.pkcs12.PKCS12CertExportCLI.java
public void execute(String[] args) throws Exception { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("help")) { printHelp();/*from ww w.jav a 2s . c om*/ return; } if (cmd.hasOption("verbose")) { PKILogger.setLevel(PKILogger.Level.INFO); } else if (cmd.hasOption("debug")) { PKILogger.setLevel(PKILogger.Level.DEBUG); } String[] cmdArgs = cmd.getArgs(); String id = cmd.getOptionValue("cert-id"); if (cmdArgs.length < 1 && id == null) { throw new Exception("Missing certificate nickname or ID."); } if (cmdArgs.length >= 1 && id != null) { throw new Exception("Certificate nickname and ID are mutually exclusive."); } String nickname = null; byte[] certID = null; if (cmdArgs.length >= 1) { nickname = cmdArgs[0]; } else { certID = Hex.decodeHex(id.toCharArray()); } String pkcs12File = cmd.getOptionValue("pkcs12-file"); if (pkcs12File == null) { throw new Exception("Missing PKCS #12 file."); } String passwordString = cmd.getOptionValue("pkcs12-password"); if (passwordString == null) { String passwordFile = cmd.getOptionValue("pkcs12-password-file"); if (passwordFile != null) { try (BufferedReader in = new BufferedReader(new FileReader(passwordFile))) { passwordString = in.readLine(); } } } if (passwordString == null) { throw new Exception("Missing PKCS #12 password."); } Password password = new Password(passwordString.toCharArray()); String certFile = cmd.getOptionValue("cert-file"); if (certFile == null) { throw new Exception("Missing certificate file."); } try { PKCS12Util util = new PKCS12Util(); PKCS12 pkcs12 = util.loadFromFile(pkcs12File, password); Collection<PKCS12CertInfo> certInfos = new ArrayList<PKCS12CertInfo>(); if (nickname != null) { certInfos.addAll(pkcs12.getCertInfosByFriendlyName(nickname)); } else { PKCS12CertInfo certInfo = pkcs12.getCertInfoByID(certID); if (certInfo != null) { certInfos.add(certInfo); } } if (certInfos.isEmpty()) { throw new Exception("Certificate not found."); } try (PrintStream os = new PrintStream(new FileOutputStream(certFile))) { for (PKCS12CertInfo certInfo : certInfos) { X509CertImpl cert = certInfo.getCert(); os.println(Cert.HEADER); os.print(Utils.base64encode(cert.getEncoded(), true)); os.println(Cert.FOOTER); } } } finally { password.clear(); } }
From source file:org.springmodules.samples.cache.guava.service.impl.SocialServiceImplCacheTest.java
@Test @SuppressWarnings("unchecked") public void testCreatePost() { final String userName = "taha"; final Collection<Post> posts = newArrayList(newPostWithId(1, userName, "post 1"), newPostWithId(2, userName, "post 2"), newPostWithId(3, userName, "post 3")); final Post newPost = newPost(userName, "post 4"); final Collection<Post> postsAfterAdd = newArrayList(); postsAfterAdd.addAll(posts); postsAfterAdd.add(newPost);//from w ww .j a v a 2s . c o m // return a clone of the posts when(postRepository.findByUserName(userName)).thenReturn(newArrayList(posts)) .thenReturn(newArrayList(postsAfterAdd)); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { // set new post id Post post = (Post) invocation.getArguments()[0]; post.setId(posts.size() + 1); // stubbed method is void return null; } }).when(postRepository).create(newPost); // load user posts assertThat(socialService.findPostsByUserName(userName)).containsAll(posts); // verify data is in cache assertThat(posts).containsAll((Iterable<? extends Post>) postsCache.get(userName).get()); // create new post socialService.createPost(newPost); // verify cache was flushed assertThat(postsCache.getNativeCache().size()).isZero(); // reload user posts assertThat(socialService.findPostsByUserName(userName)).hasSameSizeAs(postsAfterAdd) .containsAll(postsAfterAdd).contains(newPost); // verify number of times repository was invoked verify(postRepository, times(1)).create(newPost); }
From source file:cl.ucn.disc.zoome.zui.layout.OrderedSparseGraph.java
public Collection<E> getEdges() { Collection<E> edges = new ArrayList<E>(directed_edges.keySet()); edges.addAll(undirected_edges.keySet()); return Collections.unmodifiableCollection(edges); }