List of usage examples for java.util TreeSet addAll
public boolean addAll(Collection<? extends E> c)
From source file:net.sourceforge.fenixedu.applicationTier.Servico.student.AddStudentToFinalDegreeWorkStudentGroup.java
private static Registration findSomeRegistration(final String username) { User user = User.findByUsername(username); if (user != null) { final Person person = user.getPerson(); if (person != null) { final Student student = person.getStudent(); final TreeSet<Registration> registrations = new TreeSet<Registration>( new Comparator<Registration>() { @Override public int compare(final Registration r1, final Registration r2) { final DegreeType dt1 = r1.getDegreeType(); final DegreeType dt2 = r2.getDegreeType(); return 0 - dt1.compareTo(dt2); }/*from w ww .j av a 2 s.com*/ }) { @Override public boolean add(final Registration r) { final DegreeType degreeType = r.getDegreeType(); return isValidDegreeType(degreeType) && super.add(r); } private boolean isValidDegreeType(DegreeType degreeType) { return degreeType == DegreeType.BOLONHA_MASTER_DEGREE || degreeType == DegreeType.BOLONHA_INTEGRATED_MASTER_DEGREE || degreeType == DegreeType.BOLONHA_DEGREE; } }; registrations.addAll(student.getRegistrationsSet()); return registrations.isEmpty() ? null : registrations.first(); } } return null; }
From source file:org.artifactory.maven.MavenMetadataCalculator.java
private void createVersionsMetadata(RepoPath repoPath, List<ItemNode> versionNodes) { // get artifact info from the first pom RepoPath samplePomRepoPath = getFirstPom(versionNodes); if (samplePomRepoPath == null) { //Should never really be null, we've checked the list of version nodes for poms before passing it into here return;//from www.j a v a 2 s . c om } MavenArtifactInfo artifactInfo = MavenArtifactInfo.fromRepoPath(samplePomRepoPath); if (!artifactInfo.isValid()) { return; } Metadata metadata = new Metadata(); metadata.setGroupId(artifactInfo.getGroupId()); metadata.setArtifactId(artifactInfo.getArtifactId()); metadata.setVersion(artifactInfo.getVersion()); Versioning versioning = new Versioning(); metadata.setVersioning(versioning); versioning.setLastUpdatedTimestamp(new Date()); MavenMetadataVersionComparator comparator = createVersionComparator(); TreeSet<ItemNode> sortedVersions = Sets.newTreeSet(comparator); sortedVersions.addAll(versionNodes); // add the versions to the versioning section for (ItemNode sortedVersion : sortedVersions) { versioning.addVersion(sortedVersion.getName()); } // latest is simply the last (be it snapshot or release version) String latestVersion = sortedVersions.last().getName(); versioning.setLatest(latestVersion); // release is the latest non snapshot version for (ItemNode sortedVersion : sortedVersions) { String versionNodeName = sortedVersion.getName(); if (!MavenNaming.isSnapshot(versionNodeName)) { versioning.setRelease(versionNodeName); } } saveMetadata(repoPath, metadata); }
From source file:net.spfbl.whois.Domain.java
public static synchronized TreeSet<String> getTLDSet() throws ProcessException { TreeSet<String> tldSet = new TreeSet<String>(); tldSet.addAll(TLD_SET); return tldSet; }
From source file:org.apilytic.currency.service.impl.DefaultTwitterService.java
/** {@inheritDoc} */ @Override//from ww w . j av a 2s . c o m public SortedSet<TwitterMessage> getTwitterMessages(Long tweetId, SortOrder sortOrder) { final TreeSet<TwitterMessage> tweets = new TreeSet<TwitterMessage>(); if (tweetId != null) { final Map<Long, TwitterMessage> twitterMessagesAsMap = twitterMessages.asMap(); for (Long id : twitterMessagesAsMap.keySet()) { if (id.compareTo(tweetId) > 0) { tweets.add(twitterMessages.getIfPresent(id)); } } } else { tweets.addAll(this.twitterMessages.asMap().values()); } if (SortOrder.DESCENDING.equals(sortOrder)) { return tweets.descendingSet(); } return tweets; }
From source file:net.spfbl.whois.Domain.java
public static synchronized TreeSet<Domain> getDomainSet() { TreeSet<Domain> domainSet = new TreeSet<Domain>(); domainSet.addAll(MAP.values()); return domainSet; }
From source file:net.spfbl.whois.Domain.java
public static synchronized TreeSet<String> getDomainNameSet() { TreeSet<String> domainSet = new TreeSet<String>(); domainSet.addAll(MAP.keySet()); return domainSet; }
From source file:net.sourceforge.fenixedu.domain.Department.java
public Set<CycleType> getCycleTypes() { TreeSet<CycleType> cycles = new TreeSet<CycleType>(); for (DegreeType degreeType : getDegreeTypes()) { cycles.addAll(degreeType.getCycleTypes()); }/*from w w w. ja v a 2 s .c o m*/ return cycles; }
From source file:org.fenixedu.academic.thesis.ui.controller.ConfigurationController.java
@RequestMapping(value = "/create", method = RequestMethod.POST) public ModelAndView createConfiguration(@ModelAttribute ConfigurationBean configurationBean, Model model) { try {/*from w w w . j a v a2 s . c o m*/ if (configurationBean.getExecutionDegree() == null) { model.addAttribute("unselectedExecutionDegreeException", true); return createConfigurationForm(model, configurationBean); } new ConfigurationBean.Builder(configurationBean).build(); } catch (ConsistencyException exception) { model.addAttribute("createException", true); model.addAttribute("command", configurationBean); TreeSet<ExecutionYear> executionYearsList = new TreeSet<ExecutionYear>( ExecutionYear.REVERSE_COMPARATOR_BY_YEAR); executionYearsList.addAll(Bennu.getInstance().getExecutionYearsSet()); model.addAttribute("executionYearsList", executionYearsList); return new ModelAndView("/configuration/create", model.asMap()); } catch (IllegalArgumentException exception) { model.addAttribute("illegalArgumentException", true); model.addAttribute("command", configurationBean); TreeSet<ExecutionYear> executionYearsList = new TreeSet<ExecutionYear>( ExecutionYear.REVERSE_COMPARATOR_BY_YEAR); executionYearsList.addAll(Bennu.getInstance().getExecutionYearsSet()); model.addAttribute("executionYearsList", executionYearsList); return new ModelAndView("/configuration/create", model.asMap()); } catch (OverlappingIntervalsException e) { model.addAttribute("overlappingIntervalsException", true); model.addAttribute("command", configurationBean); TreeSet<ExecutionYear> executionYearsList = new TreeSet<ExecutionYear>( ExecutionYear.REVERSE_COMPARATOR_BY_YEAR); executionYearsList.addAll(Bennu.getInstance().getExecutionYearsSet()); model.addAttribute("executionYearsList", executionYearsList); return new ModelAndView("/configuration/create", model.asMap()); } return new ModelAndView("redirect:/configuration"); }
From source file:jenkins.plugins.openstack.compute.internal.Openstack.java
public @Nonnull Collection<Image> getSortedImages() { List<? extends Image> images = client.images().listAll(); TreeSet<Image> set = new TreeSet<>(RESOURCE_COMPARATOR); // Eliminate duplicate names set.addAll(images); return set;// w ww . j a v a2s . c o m }
From source file:net.sourceforge.pmd.benchmark.TextTimingReportRenderer.java
private void renderCategoryMeasurements(final TimedOperationCategory category, final Map<String, TimedResult> labeledMeasurements, final Writer writer) throws IOException { renderHeader(category.displayName(), writer); final TimedResult grandTotal = new TimedResult(); final TreeSet<Map.Entry<String, TimedResult>> sortedKeySet = new TreeSet<>( new Comparator<Map.Entry<String, TimedResult>>() { @Override//from www .j a v a 2s. c o m public int compare(final Entry<String, TimedResult> o1, final Entry<String, TimedResult> o2) { return Long.compare(o1.getValue().selfTimeNanos.get(), o2.getValue().selfTimeNanos.get()); } }); sortedKeySet.addAll(labeledMeasurements.entrySet()); for (final Map.Entry<String, TimedResult> entry : sortedKeySet) { renderMeasurement(entry.getKey(), entry.getValue(), writer); grandTotal.mergeTimes(entry.getValue()); } writer.write(PMD.EOL); renderMeasurement("Total " + category.displayName(), grandTotal, writer); writer.write(PMD.EOL); }