List of usage examples for java.util Set addAll
boolean addAll(Collection<? extends E> c);
From source file:de.bund.bfr.knime.pmmlite.core.PmmUtils.java
public static List<Variable> getVariables(ModelFormula formula) { Set<Variable> variables = new LinkedHashSet<>(); if (formula.getDepVar() != null) { variables.add(formula.getDepVar()); }//from ww w.j av a2 s . c om variables.addAll(getIndependentVariables(formula)); return new ArrayList<>(variables); }
From source file:com.offbynull.portmapper.upnpigd.UpnpIgdDiscovery.java
/** * Discovers UPNP-IGD routers./*w w w. j a va 2s . c o m*/ * @return a collection of UPNP-IGD routers that were discovered * @throws InterruptedException if interrupted * @throws IOException if IO error occurs */ public static Set<UpnpIgdService> discover() throws IOException, InterruptedException { Set<UpnpIgdDevice> devices = new HashSet<>(); devices.addAll(findIpv4Devices()); devices.addAll(findIpv6Devices()); Map<UpnpIgdDevice, byte[]> rootXmls = getRootXmlForEachDevice(devices); Set<UpnpIgdServiceReference> services = parseServiceReferences(rootXmls); Map<UpnpIgdServiceReference, byte[]> scpds = getServiceDescriptions(services); Set<UpnpIgdService> serviceDescs = parseServiceDescriptions(scpds); return serviceDescs; }
From source file:net.landora.video.utils.UIUtils.java
public static MultiValueMap createCompleteContextByClass(Collection<?> context) { Collection<Object> fullContext = UIUtils.createCompleteContext(context); MultiValueMap valuesByClass = new MultiValueMap(); Set<Class<?>> allClasses = new HashSet<Class<?>>(); for (Object obj : fullContext) { Class<?> clazz = obj.getClass(); allClasses.clear();/*from ww w. jav a 2 s .com*/ while (clazz != null) { allClasses.add(clazz); allClasses.addAll(Arrays.asList(clazz.getInterfaces())); clazz = clazz.getSuperclass(); } for (Class<?> c : allClasses) { valuesByClass.put(c, obj); } } return valuesByClass; }
From source file:hudson.security.GlobalMatrixAuthorizationStrategy.java
/** * Due to HUDSON-2324, we want to inject Item.READ permission to everyone who has Hudson.READ, * to remain backward compatible.//w w w. ja v a 2 s .co m * @param grantedPermissions */ /*package*/ static boolean migrateHudson2324(Map<Permission, Set<String>> grantedPermissions) { boolean result = false; if (Jenkins.getInstance().isUpgradedFromBefore(new VersionNumber("1.300.*"))) { Set<String> f = grantedPermissions.get(Jenkins.READ); if (f != null) { Set<String> t = grantedPermissions.get(Item.READ); if (t != null) result = t.addAll(f); else { t = new HashSet<String>(f); result = true; } grantedPermissions.put(Item.READ, t); } } return result; }
From source file:eu.h2020.symbiote.ontology.validation.ValidationHelper.java
public static Set<String> getDefinedResourcesInNamespace(OntModel model, String namespace) { // check everyhting that has rdf:type Set<String> result = model.listSubjectsWithProperty(RDF.type) .filterKeep(x -> x.getNameSpace() != null && x.getNameSpace().equals(namespace)) .mapWith(x -> x.toString()).toSet(); // check all individuals result.addAll(model.listIndividuals() .filterKeep(x -> x.getNameSpace() != null && x.getNameSpace().equals(namespace)) .mapWith(x -> x.toString()).toSet()); return result; }
From source file:de.micromata.genome.util.runtime.ClassUtils.java
/** * Returns all 'visible' methods for the given class. Visible methods are: * * - own methods (clazz.getDeclaredMethods()) - all public and protected methods from it's inheritance hierarchy * * @param clazz the Class//from www . java 2 s.c o m * @return set of visible methods for that class */ public static Set<Method> getAllVisibleMethods(final Class<?> clazz) { Set<Method> allMethods = new HashSet<>(); allMethods.addAll(Arrays.asList(clazz.getMethods())); allMethods.addAll(Arrays.asList(clazz.getDeclaredMethods())); for (Object obj : ClassUtils.getAllSuperclasses(clazz)) { Class aClass = (Class) obj; for (Method method : aClass.getDeclaredMethods()) { if (Modifier.isProtected(method.getModifiers())) { allMethods.add(method); } } } return allMethods; }
From source file:net.andydvorak.intellij.lessc.fs.LessFile.java
private static Set<LessFile> mergeSets(@NotNull final Set<LessFile> paths1, @NotNull final Set<LessFile> paths2) { final Set<LessFile> mergedPaths = new LinkedHashSet<LessFile>(); mergedPaths.addAll(paths1); mergedPaths.addAll(paths2);/*from w ww .java 2 s .c o m*/ return mergedPaths; }
From source file:com.fizzed.rocker.compiler.RockerUtil.java
public static Collection<File> listFileTree(File dir) { Set<File> fileTree = new HashSet<>(); for (File entry : dir.listFiles()) { if (entry.isFile()) fileTree.add(entry);/* ww w . java 2s . c o m*/ else fileTree.addAll(listFileTree(entry)); } return fileTree; }
From source file:com.hurence.logisland.classloading.PluginProxy.java
/** * Return all interfaces that the given class implements as a Set, * including ones implemented by superclasses. * <p>If the class itself is an interface, it gets returned as sole interface. * * @param clazz the class to analyze for interfaces * @param classLoader the ClassLoader that the interfaces need to be visible in * (may be {@code null} when accepting all declared interfaces) * @return all interfaces that the given object implements as a Set *///from ww w.j a v a 2 s. c o m public static Set<Class<?>> getAllInterfacesForClassAsSet(Class<?> clazz, ClassLoader classLoader) { if (clazz.isInterface() && isVisible(clazz, classLoader)) { return Collections.<Class<?>>singleton(clazz); } Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>(); Class<?> current = clazz; while (current != null) { Class<?>[] ifcs = current.getInterfaces(); for (Class<?> ifc : ifcs) { interfaces.addAll(getAllInterfacesForClassAsSet(ifc, classLoader)); } current = current.getSuperclass(); } return interfaces; }
From source file:com.textocat.textokit.commons.util.CorpusUtils.java
public static List<CorpusSplit> createCrossValidationSplits(File corpusDir, IOFileFilter corpusFileFilter, IOFileFilter corpusSubDirFilter, final int foldsNum) { List<Set<File>> corpusPartitions = partitionCorpusByFileSize(corpusDir, corpusFileFilter, corpusSubDirFilter, foldsNum); List<CorpusSplit> result = Lists.newArrayListWithExpectedSize(foldsNum); for (int f = 0; f < foldsNum; f++) { Set<File> trainingSet = Sets.newLinkedHashSet(); Set<File> testingSet = corpusPartitions.get(f); // fill training set for (int i = 0; i < corpusPartitions.size(); i++) { if (i != f) { trainingSet.addAll(corpusPartitions.get(i)); }// w w w . j a v a 2s. c om } Function<File, String> relPathFunc = relativePathFunction(corpusDir); result.add(new DefaultCorpusSplit(transform(trainingSet, relPathFunc), transform(testingSet, relPathFunc))); } // sanity check if (result.size() != foldsNum) { throw new IllegalStateException(); } return result; }