List of usage examples for java.util HashSet addAll
boolean addAll(Collection<? extends E> c);
From source file:org.apache.hadoop.yarn.server.resourcemanager.security.RMDelegationTokenSecretManager.java
@Private @VisibleForTesting/*w ww . j a v a 2s . c om*/ public synchronized Set<DelegationKey> getAllMasterKeys() { HashSet<DelegationKey> keySet = new HashSet<DelegationKey>(); keySet.addAll(allKeys.values()); return keySet; }
From source file:io.fabric8.profiles.Profiles.java
/** * @param target is the directory where resulting materialized profile configuration will be written to. * @param profileNames a list of profile names that will be combined to create the materialized profile. *///w w w . ja v a 2 s.co m public void materialize(Path target, String... profileNames) throws IOException { ArrayList<String> profileSearchOrder = new ArrayList<>(); for (String profileName : profileNames) { collectProfileNames(profileSearchOrder, profileName); } HashSet<String> files = new HashSet<>(); for (String profileName : profileSearchOrder) { files.addAll(listFiles(profileName)); } System.out.println("profile search order" + profileSearchOrder); System.out.println("files: " + files); for (String file : files) { try (InputStream is = materializeFile(file, profileSearchOrder)) { Files.copy(is, target.resolve(file), StandardCopyOption.REPLACE_EXISTING); } } }
From source file:de.sindzinski.wetter.util.Utility.java
public static HashSet<TextView> getTextViews(ViewGroup root) { HashSet<TextView> views = new HashSet<>(); for (int i = 0; i < root.getChildCount(); i++) { View v = root.getChildAt(i); if (v instanceof TextView) { views.add((TextView) v);/*ww w. j a v a 2s . co m*/ } else if (v instanceof ViewGroup) { views.addAll(getTextViews((ViewGroup) v)); } } return views; }
From source file:com.nomprenom2.view.NameParamsFragment.java
/** * Fills region view with fragments: adds selected and deletes deselected *//*w ww.j a v a 2 s . c o m*/ private void setGroupList() { View v = getView(); if (v != null && v.findViewById(R.id.fragment_container) != null) { HashSet<String> regs = new HashSet<>(); regs.addAll(regions); // copy regions set for processing FragmentManager mngr = getFragmentManager(); FragmentTransaction tr = mngr.beginTransaction(); Fragment fr; // clear fragments not in region list Iterator<WeakReference<Fragment>> it = frag_list.iterator(); while (it.hasNext()) { WeakReference<Fragment> f = it.next(); fr = f.get(); if (fr != null) { String tg = fr.getTag(); if (!regs.contains(tg)) { tr.remove(fr); it.remove(); // remove deleted region from fragments list } else { regs.remove(tg); // remove processed region } } } // add remained regions for (String s : regs) { fr = FragmentItem.newInstance(s, this); tr.add(R.id.fragment_container, fr, s); frag_list.add(new WeakReference<>(fr)); } tr.commit(); } }
From source file:com.salesmanager.core.service.catalog.impl.db.dao.ProductDescriptionDao.java
public Set<ProductDescription> findByProductId(long id) { try {/* w ww . ja v a 2 s .co m*/ List descriptions = super.getSession().createCriteria(ProductDescription.class) .add(Restrictions.eq("id.productId", id)).list(); HashSet set = new HashSet(); set.addAll(descriptions); return set; } catch (RuntimeException re) { log.error("get failed", re); throw re; } }
From source file:at.bitfire.davdroid.mirakel.webdav.TlsSniSocketFactory.java
@SuppressLint("DefaultLocale") private void setReasonableEncryption(SSLSocket ssl) { // set reasonable SSL/TLS settings before the handshake // Android 5.0+ (API level21) provides reasonable default settings // but it still allows SSLv3 // https://developer.android.com/about/versions/android-5.0-changes.html#ssl // - enable all supported protocols (enables TLSv1.1 and TLSv1.2 on Android <5.0, if available) // - remove all SSL versions (especially SSLv3) because they're insecure now List<String> protocols = new LinkedList<String>(); for (String protocol : ssl.getSupportedProtocols()) if (!protocol.toUpperCase().contains("SSL")) protocols.add(protocol);/*from w ww.j ava2 s . c o m*/ Log.v(TAG, "Setting allowed TLS protocols: " + StringUtils.join(protocols, ", ")); ssl.setEnabledProtocols(protocols.toArray(new String[0])); if (android.os.Build.VERSION.SDK_INT < 21) { // choose secure cipher suites List<String> allowedCiphers = Arrays.asList(// TLS 1.2 "TLS_RSA_WITH_AES_256_GCM_SHA384", "TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECHDE_RSA_WITH_AES_128_GCM_SHA256", // maximum interoperability "TLS_RSA_WITH_3DES_EDE_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA", // additionally "TLS_RSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA"); List<String> availableCiphers = Arrays.asList(ssl.getSupportedCipherSuites()); // preferred ciphers = allowed Ciphers \ availableCiphers HashSet<String> preferredCiphers = new HashSet<String>(allowedCiphers); preferredCiphers.retainAll(availableCiphers); // add preferred ciphers to enabled ciphers // for maximum security, preferred ciphers should *replace* enabled ciphers, // but I guess for the security level of DAVdroid, disabling of insecure // ciphers should be a server-side task HashSet<String> enabledCiphers = preferredCiphers; enabledCiphers.addAll(new HashSet<String>(Arrays.asList(ssl.getEnabledCipherSuites()))); Log.v(TAG, "Setting allowed TLS ciphers: " + StringUtils.join(enabledCiphers, ", ")); ssl.setEnabledCipherSuites(enabledCiphers.toArray(new String[0])); } }
From source file:com.googlesource.gerrit.plugins.github.oauth.GitHubLogin.java
private SortedSet<Scope> getScopes(String baseScopeKey, Scope... scopes) { HashSet<Scope> fullScopes = new HashSet<Scope>(scopesForKey(baseScopeKey)); fullScopes.addAll(Arrays.asList(scopes)); return new TreeSet<Scope>(fullScopes); }
From source file:org.cgiar.ccafs.marlo.action.center.json.monitoring.outcome.OutcomeTreeAction.java
@Override public String execute() throws Exception { List<CenterProject> projects = new ArrayList<>(); CenterOutcome outcome = outcomeService.getResearchOutcomeById(outcomeID); List<CenterOutput> outputs = new ArrayList<>(); List<CenterOutputsOutcome> centerOutputsOutcomes = new ArrayList<>(outcome.getCenterOutputsOutcomes() .stream().filter(ro -> ro.isActive()).collect(Collectors.toList())); for (CenterOutputsOutcome centerOutputsOutcome : centerOutputsOutcomes) { outputs.add(centerOutputsOutcome.getCenterOutput()); }//w w w . j av a 2 s . c o m if (!outputs.isEmpty()) { for (CenterOutput researchOutput : outputs) { List<CenterProjectOutput> projectOutputs = new ArrayList<>(researchOutput.getProjectOutputs() .stream().filter(po -> po.isActive()).collect(Collectors.toList())); if (!projectOutputs.isEmpty()) { for (CenterProjectOutput projectOutput : projectOutputs) { if (projectOutput.getProject().isActive()) { projects.add(projectOutput.getProject()); } } } } } HashSet<CenterProject> hashProjects = new HashSet<>(); hashProjects.addAll(projects); projects = new ArrayList<>(hashProjects); this.dataProjects = new ArrayList<>(); for (CenterProject project : hashProjects) { Map<String, Object> dataProject = new HashMap<>(); dataProject.put("id", project.getId()); dataProject.put("name", project.getName()); List<CenterProjectOutput> projectOutputs = new ArrayList<>( project.getProjectOutputs().stream().filter(po -> po.isActive()).collect(Collectors.toList())); List<Map<String, Object>> dataOutputs = new ArrayList<>(); if (!projectOutputs.isEmpty()) { for (CenterProjectOutput projectOutput : projectOutputs) { Map<String, Object> dataOutput = new HashMap<>(); dataOutput.put("id", projectOutput.getResearchOutput().getId()); dataOutput.put("name", projectOutput.getResearchOutput().getTitle()); dataOutputs.add(dataOutput); } } dataProject.put("outputs", dataOutputs); List<CenterDeliverable> deliverables = new ArrayList<>( project.getDeliverables().stream().filter(d -> d.isActive()).collect(Collectors.toList())); List<Map<String, Object>> dataDeliverables = new ArrayList<>(); if (!deliverables.isEmpty()) { for (CenterDeliverable deliverable : deliverables) { Map<String, Object> dataDeliverable = new HashMap<>(); dataDeliverable.put("id", deliverable.getId()); dataDeliverable.put("name", deliverable.getName()); dataDeliverables.add(dataDeliverable); } } dataProject.put("deliverables", dataDeliverables); this.dataProjects.add(dataProject); } return SUCCESS; }
From source file:byps.http.HActiveMessage.java
public synchronized boolean checkReferencedStreamIds(HashSet<Long> allStreamIds, HashSet<Long> referencedStreamIds) { incomingStreams = evalM1AndM2(incomingStreams, allStreamIds); referencedStreamIds.addAll(incomingStreams); checkFinished();//from w w w .j av a 2s . c o m return isFinished(); }
From source file:com.github.frapontillo.pulse.crowd.lemmatize.morphit.MorphITLemmatizer.java
/** * Build the TANL-to-MorphIT mapping dictionary as <key:(tanl-tag), * value:(morphit-tag-1,...)>./*from w ww . ja va 2 s . c o m*/ * Values are read from the resource file "tanl-morphit". * * @return A {@link HashMap} where the key is a {@link String} representing the TANL tag and * values are {@link Set}s of all the MorphIT tag {@link String}s. */ private HashMap<String, HashSet<String>> getTanlMorphITMap() { if (tanlMorphITMap == null) { InputStream mapStream = MorphITLemmatizer.class.getClassLoader().getResourceAsStream("tanl-morphit"); tanlMorphITMap = new HashMap<>(); try { List<String> mapLines = IOUtils.readLines(mapStream, Charset.forName("UTF-8")); mapLines.forEach(s -> { // for each line, split using spaces String[] values = spacePattern.split(s); if (values.length > 0) { // the first token is the key String key = values[0]; // all subsequent tokens are possible values HashSet<String> valueSet = new HashSet<>(); valueSet.addAll(Arrays.asList(values).subList(1, values.length)); tanlMorphITMap.put(key, valueSet); } }); } catch (IOException e) { e.printStackTrace(); } } return tanlMorphITMap; }