List of usage examples for java.util Set addAll
boolean addAll(Collection<? extends E> c);
From source file:grails.plugin.searchable.internal.support.DynamicMethodUtils.java
/** * Extract the property names from the given method name suffix accoring * to the given Class's properties//from w w w . ja va 2 s. co m * * @param clazz the Class to resolve property names against * @param methodSuffix a method name suffix like 'NameAndAddressCity' * @return a Collection of property names like ['name', 'address'] */ public static Collection extractPropertyNames(Class clazz, String methodSuffix) { String joinedNames = methodSuffix; Set propertyNames = new HashSet(); PropertyDescriptor[] propertyDescriptors = BeanUtils.getPropertyDescriptors(clazz); for (int i = 0; i < propertyDescriptors.length; i++) { String name = propertyDescriptors[i].getName(); String capitalized = name.substring(0, 1).toUpperCase() + name.substring(1); if (joinedNames.indexOf(capitalized) > -1) { // uses indexOf instead of contains for Java 1.4 compatibility propertyNames.add(name); joinedNames = DefaultGroovyMethods.minus(joinedNames, capitalized); } } if (joinedNames.length() > 0) { propertyNames.addAll(extractPropertyNames(joinedNames)); } return propertyNames; }
From source file:com.taobao.tddl.interact.rule.VirtualTable.java
private static void valuebyvalue(Map<String, Set<String>> topology, Rule<String> dbRule, Rule<String> tbRule, boolean isVnode) { Map<String/**/, Set<Object>> dbEnumerates = getEnumerates(dbRule); Map<String/**/, Set<Object>> tbEnumerates = getEnumerates(tbRule); //Samples dbSamples = new Samples(dbEnumerates); //Samples tbSamples = new Samples(tbEnumerates); Set<AdvancedParameter> params = cast(tbRule.getRuleColumnSet()); for (AdvancedParameter tbap : params) { if (dbEnumerates.containsKey(tbap.key)) { //= =! Set<Object> tbValuesBasedONdbValue = new HashSet<Object>(); for (Object dbValue : dbEnumerates.get(tbap.key)) { tbValuesBasedONdbValue.addAll(tbap.enumerateRange(dbValue)); }//from w w w . j a v a 2 s .co m dbEnumerates.get(tbap.key).addAll(tbValuesBasedONdbValue); } else { dbEnumerates.put(tbap.key, tbEnumerates.get(tbap.key)); } } // if (isVnode) { Samples tabSamples = new Samples(tbEnumerates); Set<String> tbs = new TreeSet<String>(); for (Map<String, Object> sample : tabSamples) { String value = tbRule.eval(sample, null); tbs.add(value); } for (String table : tbs) { Map<String, Object> sample = new HashMap<String, Object>(1); sample.put(EnumerativeRule.REAL_TABLE_NAME_KEY, table); String db = dbRule.eval(sample, null); if (topology.get(db) == null) { Set<String> tabs = new HashSet<String>(); tabs.add(table); topology.put(db, tabs); } else { topology.get(db).add(table); } } return; } // Map<String, Samples> dbs = vbvTrace(dbRule, dbEnumerates);// for (Map.Entry<String/**/, Samples> e : dbs.entrySet()) { Set<String> tbs = topology.get(e.getKey()); if (tbs == null) { tbs = vbvRule(tbRule, e.getValue()); topology.put(e.getKey(), tbs); } else { tbs.addAll(vbvRule(tbRule, e.getValue())); } } }
From source file:de.bund.bfr.knime.pmmlite.core.PmmUtils.java
public static Set<TimeSeries> getData(Collection<? extends Model> models) { Set<TimeSeries> data = new LinkedHashSet<>(); for (Model model : models) { if (model instanceof PrimaryModel) { data.add(((PrimaryModel) model).getData()); } else if (model instanceof SecondaryModel) { ((SecondaryModel) model).getData().forEach(m -> data.add(m.getData())); } else if (model instanceof TertiaryModel) { data.addAll(((TertiaryModel) model).getData()); }// ww w . j a v a2 s. c o m } return data; }
From source file:org.cloudifysource.quality.iTests.test.cli.cloudify.util.NewRestTestUtils.java
private static void waitForManagersToShutDown(final ControllerDetails[] managers, final int port, final long timeoutMinutes) throws InterruptedException, TimeoutException, CLIException { final Set<ControllerDetails> managersStillUp = new HashSet<ControllerDetails>(); managersStillUp.addAll(Arrays.asList(managers)); final ConditionLatch conditionLatch = new ConditionLatch() .pollingInterval(POLLING_INTERVAL_MILLISECONDS, TimeUnit.MILLISECONDS) .timeout(timeoutMinutes, TimeUnit.MINUTES) .timeoutErrorMessage(CloudifyErrorMessages.SHUTDOWN_MANAGERS_TIMEOUT.getName()); conditionLatch.waitFor(new ConditionLatch.Predicate() { @Override//from w ww. j a va 2 s .c o m public boolean isDone() throws CLIException, InterruptedException { final Iterator<ControllerDetails> iterator = managersStillUp.iterator(); while (iterator.hasNext()) { final ControllerDetails manager = iterator.next(); final String host = manager.isBootstrapToPublicIp() ? manager.getPublicIp() : manager.getPrivateIp(); if (ServiceUtils.isPortFree(host, port)) { iterator.remove(); LogUtils.log("Manager [" + host + "] is down."); if (managersStillUp.isEmpty()) { LogUtils.log("All ports are free."); return true; } LogUtils.log(managersStillUp.size() + " managers more to check"); } else { LogUtils.log("Manager [" + host + "] is still up."); } } return false; } }); }
From source file:com.smart.utils.ReflectionUtils.java
/** * ?Class?(?),ListClass/* w w w. j ava2 s.c o m*/ * * @param bean * @return */ public static List<Class> getAllInterfaceOfClazz(Class clz) { List allClass = getAllClassesOfClazz(clz); // ?? Set s = new HashSet(); for (int i = 0; i < allClass.size(); i++) { Class clazz = (Class) allClass.get(i); List temp = getInterfaceOfClass(clazz); s.addAll(temp); } List result = new LinkedList(); Iterator itrt = s.iterator(); while (itrt.hasNext()) { Class c = (Class) itrt.next(); result.add(c); } return result; }
From source file:mailbox.EmailHandler.java
/** * Returns the threads to which the given message is sent. * * The threads are determined by message-ids in In-Reply-To and References * headers and the detail part of the recipients' email addresses. * * @param msg/*from w ww .j a v a2 s . com*/ * @return * @throws MessagingException */ private static Set<Resource> getThreads(IMAPMessage msg) throws MessagingException { // Get message-ids from In-Reply-To and References headers. Set<String> messageIds = new HashSet<>(); String inReplyTo = msg.getInReplyTo(); if (inReplyTo != null) { messageIds.addAll(parseMessageIds(inReplyTo)); } for (String references : ArrayUtils.nullToEmpty(msg.getHeader("References"))) { if (references != null) { messageIds.addAll(parseMessageIds(references)); } } // Find threads by the message-id. Set<Resource> threads = new HashSet<>(); for (String messageId : messageIds) { for (Resource resource : findResourcesByMessageId(messageId)) { switch (resource.getType()) { case COMMENT_THREAD: case ISSUE_POST: case BOARD_POST: threads.add(resource); break; case REVIEW_COMMENT: threads.add(resource.getContainer()); break; default: Logger.info("Cannot comment a resource of unknown type: " + resource); break; } } } for (EmailAddressWithDetail address : getMailAddressesToYobi(msg.getAllRecipients())) { Resource thread = getResourceFromDetail(address.getDetail()); if (thread != null) { threads.add(thread); } } return threads; }
From source file:com.github.anba.es6draft.util.Resources.java
/** * Reads all exlusion xml-files from the configuration. *///from w w w . j a v a2s . co m private static Set<String> readExcludeXMLs(List<?> values, Path basedir) throws IOException { Set<String> exclude = new HashSet<>(); for (String s : nonEmpty(values)) { try (InputStream res = Resources.resource(s, basedir)) { exclude.addAll(readExcludeXML(res)); } } return exclude; }
From source file:org.eclipse.virgo.ide.runtime.core.provisioning.RepositoryUtils.java
/** * Downloads the given <code>artifacts</code>. *//*from w ww . j av a 2 s . c o m*/ public static void downloadArifacts(final Set<Artefact> artifacts, final IProject project, final Shell shell, boolean resolveDependencies) { if (resolveDependencies) { artifacts.addAll(resolveDependencies(artifacts, false)); } final Set<IRuntime> runtimes = new HashSet<IRuntime>(); ServerRuntimeUtils.execute(project, new ServerRuntimeUtils.ServerRuntimeCallback() { public boolean doWithRuntime(VirgoServerRuntime runtime) { runtimes.add(runtime.getRuntime()); return true; } }); if (runtimes.size() > 0) { IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { RepositoryProvisioningJob job = new RepositoryProvisioningJob(runtimes, artifacts, true); job.run(monitor); } }; try { IRunnableContext context = new ProgressMonitorDialog(shell); context.run(true, true, runnable); } catch (InvocationTargetException e1) { } catch (InterruptedException e2) { } } }
From source file:it.units.malelab.ege.util.Utils.java
public static <T> boolean validate(Node<T> tree, Grammar<T> grammar) { if (tree == null) { return false; }//from w ww .j a va2s .c o m if (!tree.getContent().equals(grammar.getStartingSymbol())) { return false; } Set<T> terminals = new LinkedHashSet<>(); for (List<List<T>> options : grammar.getRules().values()) { for (List<T> option : options) { terminals.addAll(option); } } terminals.removeAll(grammar.getRules().keySet()); return innerValidate(tree, grammar, terminals); }
From source file:com.eucalyptus.ws.util.HmacUtils.java
public static String makeSubjectString(final Map<String, String> parameters) { String paramString = ""; Set<String> sortedKeys = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); sortedKeys.addAll(parameters.keySet()); for (String key : sortedKeys) paramString = paramString.concat(key).concat(parameters.get(key).replaceAll("\\+", " ")); try {/* w ww . ja v a 2 s . c o m*/ return new String(URLCodec.decodeUrl(paramString.getBytes())); } catch (DecoderException e) { return paramString; } }