List of usage examples for java.util Set addAll
boolean addAll(Collection<? extends E> c);
From source file:net.sourceforge.fenixedu.domain.Professorship.java
public static List<Professorship> readByDegreeCurricularPlanAndExecutionYear( DegreeCurricularPlan degreeCurricularPlan, ExecutionYear executionYear) { Set<Professorship> professorships = new HashSet<Professorship>(); for (CurricularCourse curricularCourse : degreeCurricularPlan.getCurricularCoursesSet()) { for (ExecutionCourse executionCourse : curricularCourse .getExecutionCoursesByExecutionYear(executionYear)) { professorships.addAll(executionCourse.getProfessorshipsSet()); }//from w w w .jav a2 s . c o m } return new ArrayList<Professorship>(professorships); }
From source file:gov.nasa.jpf.constraints.solvers.cw.CWSolver.java
private static <T> Set<T> union(Collection<T> collection1, Collection<T> collection2) { Set<T> result = new HashSet<>(); result.addAll(collection1); result.addAll(collection2);//from ww w.j a va 2s . c o m return result; }
From source file:eu.planets_project.tb.impl.services.ServiceRegistryManager.java
/** * // w w w . j a v a2 s . c om * @return */ @Deprecated public static List<URI> listAvailableEndpoints() { Set<URI> uniqueSE = new HashSet<URI>(); // Inspect the local JBossWS endpoints: try { String authority = PlanetsServerConfig.getHostname() + ":" + PlanetsServerConfig.getPort(); URI uriPage = new URI("http", authority, "/jbossws/services", null, null); //2) extract the page's content: note: not well-formed --> modifications String pageContent = readUrlContents(uriPage); //3) build a dom tree and extract the text nodes //String xPath = new String("/*//fieldset/table/tbody/tr/td/a/@href"); uniqueSE.addAll(extractEndpointsFromWebPage(pageContent)); } catch (Exception e) { log.error("Lookup of JBossWS services failed! : " + e); } // Now sort the list and return it. List<URI> sList = new ArrayList<URI>(uniqueSE); java.util.Collections.sort(sList); return sList; }
From source file:net.sourceforge.fenixedu.domain.Professorship.java
public static List<Professorship> readByDegreeCurricularPlanAndExecutionPeriod( DegreeCurricularPlan degreeCurricularPlan, ExecutionSemester executionSemester) { Set<Professorship> professorships = new HashSet<Professorship>(); for (CurricularCourse curricularCourse : degreeCurricularPlan.getCurricularCoursesSet()) { for (ExecutionCourse executionCourse : curricularCourse .getExecutionCoursesByExecutionPeriod(executionSemester)) { professorships.addAll(executionCourse.getProfessorshipsSet()); }/*w w w.j a v a 2 s . co m*/ } return new ArrayList<Professorship>(professorships); }
From source file:org.eclipse.virgo.ide.runtime.core.provisioning.RepositoryUtils.java
/** * Resolves dependencies of given <code>artefacts</code>. Currently this implementation only resolves direct bundle * dependencies of {@link LibraryArtefact}s. *///from w w w .jav a2s . co m public static Set<Artefact> resolveDependencies(Set<Artefact> artifacts, boolean includeOptional) { Set<Artefact> resolvedArtefacts = new HashSet<Artefact>(artifacts); // resolve library dependencies for (IArtefactTyped artefact : artifacts) { if (artefact instanceof LibraryArtefact) { resolvedArtefacts.addAll(ServerCorePlugin.getArtefactRepositoryManager() .findLibraryDependencies((LibraryArtefact) artefact, includeOptional)); } } return resolvedArtefacts; }
From source file:de.tudarmstadt.ukp.dkpro.tc.core.util.TaskUtils.java
/** * Get a list of required type names./*from w w w.j av a 2s. c o m*/ */ public static Set<String> getRequiredTypesFromFeatureExtractors(List<String> featureSet) throws InstantiationException, IllegalAccessException, ClassNotFoundException { Set<String> requiredTypes = new HashSet<String>(); for (String element : featureSet) { TypeCapability annotation = ReflectionUtil.getAnnotation(Class.forName(element), TypeCapability.class); if (annotation != null) { requiredTypes.addAll(Arrays.asList(annotation.inputs())); } } return requiredTypes; }
From source file:de.tudarmstadt.ukp.wikipedia.util.GraphUtilities.java
/** Get a random subset (of size pSize) of the page set passed to the method. * @param pPageIDs The pages.//from ww w .j a v a 2s .co m * @param pResultSetSize The size of the result set. * @return A random subset of the original page set of the given size or null, if the requested subset size is larger than the original page set. */ public static Set<Integer> getRandomPageSubset(Set<Integer> pPageIDs, int pResultSetSize) { Set<Integer> uniqueRandomSet = new HashSet<Integer>(); if (pPageIDs.size() < pResultSetSize) { logger.error("Requested subset size is larger than the original page set size."); return null; } Random rand = new Random(); Object[] pageIdArray = pPageIDs.toArray(); // If pSize is quite close to the size of the original pageSet the probability of generating the offset of the last missing pageIDs is quite low, with the consequence of unpredictable run-time. // => if more than the half of pages should be included in the result set, better remove random numbers than adding them if (pResultSetSize > (pPageIDs.size() / 2)) { uniqueRandomSet.addAll(pPageIDs); while (uniqueRandomSet.size() > pResultSetSize) { int randomOffset = rand.nextInt(pPageIDs.size()); if (uniqueRandomSet.contains(pageIdArray[randomOffset])) { uniqueRandomSet.remove(pageIdArray[randomOffset]); } } } else { while (uniqueRandomSet.size() < pResultSetSize) { int randomOffset = rand.nextInt(pPageIDs.size()); if (!uniqueRandomSet.contains(pageIdArray[randomOffset])) { uniqueRandomSet.add((Integer) pageIdArray[randomOffset]); } } } return uniqueRandomSet; }
From source file:edu.uci.ics.asterix.optimizer.rules.typecast.StaticTypeCastUtil.java
/** * Determine if two types are compatible * /*from ww w . j a v a 2s .c om*/ * @param reqType * the required type * @param inputType * the input type * @return true if the two types are compatible; false otherwise */ public static boolean compatible(IAType reqType, IAType inputType) { if (reqType.getTypeTag() == ATypeTag.ANY || inputType.getTypeTag() == ATypeTag.ANY) { return true; } if (reqType.getTypeTag() != ATypeTag.UNION && inputType.getTypeTag() != ATypeTag.UNION) { if (reqType.equals(inputType)) { return true; } else { return false; } } Set<IAType> reqTypePossible = new HashSet<IAType>(); Set<IAType> inputTypePossible = new HashSet<IAType>(); if (reqType.getTypeTag() == ATypeTag.UNION) { AUnionType unionType = (AUnionType) reqType; reqTypePossible.addAll(unionType.getUnionList()); } else { reqTypePossible.add(reqType); } if (inputType.getTypeTag() == ATypeTag.UNION) { AUnionType unionType = (AUnionType) inputType; inputTypePossible.addAll(unionType.getUnionList()); } else { inputTypePossible.add(inputType); } return reqTypePossible.equals(inputTypePossible); }
From source file:com.erudika.para.core.ParaObjectUtils.java
/** * Searches through the Para core package and {@code Config.CORE_PACKAGE_NAME} package for {@link ParaObject} * subclasses and adds their names them to the map. * * @return a map of simple class names (lowercase) to class objects *///ww w .j ava 2s . c o m public static Map<String, Class<? extends ParaObject>> getCoreClassesMap() { if (coreClasses.isEmpty()) { try { Set<Class<? extends ParaObject>> s = scanner .getComponentClasses(ParaObject.class.getPackage().getName()); if (!Config.CORE_PACKAGE_NAME.isEmpty()) { Set<Class<? extends ParaObject>> s2 = scanner.getComponentClasses(Config.CORE_PACKAGE_NAME); s.addAll(s2); } for (Class<? extends ParaObject> coreClass : s) { boolean isAbstract = Modifier.isAbstract(coreClass.getModifiers()); boolean isInterface = Modifier.isInterface(coreClass.getModifiers()); boolean isCoreObject = ParaObject.class.isAssignableFrom(coreClass); if (isCoreObject && !isAbstract && !isInterface) { coreClasses.put(coreClass.getSimpleName().toLowerCase(), coreClass); } } logger.debug("Found {} ParaObject classes: {}", coreClasses.size(), coreClasses); } catch (Exception ex) { logger.error(null, ex); } } return Collections.unmodifiableMap(coreClasses); }
From source file:com.thinkbiganalytics.nifi.rest.support.NifiProcessUtil.java
/** * Return a set of processors in a template, optionally allowing the framework to traverse into a templates input ports to get the connecting process groups * * @param template a template to parse * @param excludeInputs {@code true} will traverse down into the input ports and gather processors in the conencting groups, {@code false} will traverse input ports and their respective process * groups/*from w ww. j a v a2 s . co m*/ * @return return a set of processors */ public static Set<ProcessorDTO> getProcessors(TemplateDTO template, boolean excludeInputs) { Set<ProcessorDTO> processors = new HashSet<>(); for (ProcessorDTO processorDTO : template.getSnippet().getProcessors()) { processors.add(processorDTO); } if (template.getSnippet().getProcessGroups() != null) { for (ProcessGroupDTO groupDTO : template.getSnippet().getProcessGroups()) { processors.addAll(getProcessors(groupDTO)); } } if (excludeInputs) { final List<ProcessorDTO> inputs = NifiTemplateUtil.getInputProcessorsForTemplate(template); Iterables.removeIf(processors, new Predicate<ProcessorDTO>() { @Override public boolean apply(ProcessorDTO processorDTO) { return (inputs.contains(processorDTO)); } }); } return processors; }