Example usage for java.util SortedSet add

List of usage examples for java.util SortedSet add

Introduction

In this page you can find the example usage for java.util SortedSet add.

Prototype

boolean add(E e);

Source Link

Document

Adds the specified element to this set if it is not already present (optional operation).

Usage

From source file:net.sourceforge.fenixedu.domain.candidacyProcess.mobility.MobilityApplicationProcess.java

public Map<Degree, SortedSet<MobilityIndividualApplicationProcess>> getValidErasmusIndividualCandidaciesByDegree() {
    final Map<Degree, SortedSet<MobilityIndividualApplicationProcess>> result = new TreeMap<Degree, SortedSet<MobilityIndividualApplicationProcess>>(
            Degree.COMPARATOR_BY_NAME_AND_ID);
    for (final IndividualCandidacyProcess child : getChildProcessesSet()) {
        final MobilityIndividualApplicationProcess process = (MobilityIndividualApplicationProcess) child;
        if (process.isCandidacyValid()) {
            SortedSet<MobilityIndividualApplicationProcess> values = result
                    .get(process.getCandidacySelectedDegree());
            if (values == null) {
                result.put(process.getCandidacySelectedDegree(),
                        values = new TreeSet<MobilityIndividualApplicationProcess>(
                                SecondCycleIndividualCandidacyProcess.COMPARATOR_BY_CANDIDACY_PERSON));
            }//from   w w w . j  a  v  a 2 s . co  m
            values.add(process);
        }
    }
    return result;
}

From source file:gov.nih.nci.caarray.web.action.project.ProjectFilesActionTest.java

@Test
public void testUserVisibleFiles() {
    final SortedSet<CaArrayFile> fileSet = new TreeSet<CaArrayFile>();

    final CaArrayFile file1 = new CaArrayFile();
    file1.setName("file1");
    file1.setType(AFFYMETRIX_CDF.getName());
    file1.setFileStatus(FileStatus.IMPORTED);
    fileSet.add(file1);

    final CaArrayFile file1child = new CaArrayFile(file1);
    file1child.setName("file1 child");
    file1child.setType(AFFYMETRIX_CDF.getName());
    file1child.setFileStatus(FileStatus.IMPORTED);
    fileSet.add(file1child);//from  w w w .j  ava 2s. c om

    final TestProject project = new TestProject();
    assertEquals(0, this.action.getFiles().size());
    this.action.setProject(project);

    project.setImportedFiles(fileSet);
    assertEquals(LIST_IMPORTED, this.action.listImported());
    assertEquals(1, this.action.getFiles().size());

    project.setUnimportedFiles(fileSet);
    assertEquals(LIST_UNIMPORTED, this.action.listUnimported());
    assertEquals(1, this.action.getFiles().size());

    project.setFiles(fileSet);
    assertEquals(Action.SUCCESS, this.action.downloadFiles());
    assertEquals(1, this.action.getFiles().size());

    final List<CaArrayFile> selectedFiles = new ArrayList<CaArrayFile>();
    this.action.setSelectedFiles(selectedFiles);
    selectedFiles.add(file1);
    assertEquals(LIST_UNIMPORTED, this.action.addSupplementalFiles());
    assertEquals(1, this.fileManagementServiceStub.getSupplementalFileCount());
}

From source file:gov.nih.nci.caarray.web.action.project.ProjectFilesActionTest.java

private SortedSet<CaArrayFile> getDownloadedFileSet() throws IOException {
    final SortedSet<CaArrayFile> fileSet = new TreeSet<CaArrayFile>();

    final CaArrayFile file1 = new CaArrayFile();
    file1.setName("file1");
    file1.setType(AFFYMETRIX_CDF.getName());
    file1.setFileStatus(FileStatus.IMPORTED_NOT_PARSED);
    fileSet.add(file1);

    final CaArrayFile file2 = new CaArrayFile();
    file2.setName("file2");
    file2.setType(AGILENT_CSV.getName());
    file2.setFileStatus(FileStatus.IMPORTED);
    fileSet.add(file2);/*w  w w .  j av a 2 s.com*/

    final CaArrayFile file3 = new CaArrayFile();
    file3.setName("file3");
    file3.setType(null);
    file3.setFileStatus(FileStatus.VALIDATED);
    fileSet.add(file3);

    final CaArrayFile file4 = new CaArrayFile();
    file4.setName("file4");
    file4.setType(GENEPIX_GAL.getName());
    file4.setFileStatus(FileStatus.VALIDATED_NOT_PARSED);
    fileSet.add(file4);
    return fileSet;
}

From source file:com.serli.maven.plugin.quality.mojo.LicenseMojo.java

private void put(LightLicense key, MavenProjectComparable projectArtifact) {
    // handle multiple values as a set to avoid duplicates
    SortedSet<MavenProjectComparable> valueList = null;
    Set<LightLicense> keySet = resultLicenseMap.keySet();
    String url = key.getUrl();/*from ww  w .  j ava  2 s.  co  m*/
    for (LightLicense license : keySet) {
        String urlLicense = license.getUrl();
        String nameLicense = license.getName();
        if (license.equals(key)) {
            valueList = resultLicenseMap.remove(license);
            if (Util.isArtifactUrlValid(urlLicense)) {
                key.setUrl(urlLicense);
            }
            if (StringUtils.isNotEmpty(nameLicense)) {
                key.setName(nameLicense);
            }
            break;
        }
    }

    if (valueList == null) {
        valueList = new TreeSet<MavenProjectComparable>();
    }
    valueList.add(projectArtifact);
    resultLicenseMap.put(key, valueList);
}

From source file:gov.nih.nci.caarray.web.action.project.ProjectFilesActionTest.java

private SortedSet<CaArrayFile> getUnimportedFileSet() throws IOException {
    final SortedSet<CaArrayFile> fileSet = new TreeSet<CaArrayFile>();

    final CaArrayFile file1 = new CaArrayFile();
    file1.setName("file1");
    file1.setType(AFFYMETRIX_CDF.getName());
    file1.setFileStatus(FileStatus.IMPORT_FAILED);
    fileSet.add(file1);

    final CaArrayFile file2 = new CaArrayFile();
    file2.setName("file2");
    file2.setType(AFFYMETRIX_CDF.getName());
    file2.setFileStatus(FileStatus.IMPORT_FAILED);
    fileSet.add(file2);//from   w  ww .  j a v a2 s  .co  m

    final CaArrayFile file3 = new CaArrayFile();
    file3.setName("file3");
    file3.setType(AGILENT_CSV.getName());
    file3.setFileStatus(FileStatus.IMPORT_FAILED);
    fileSet.add(file3);

    final CaArrayFile file4 = new CaArrayFile();
    file4.setName("file4");
    file4.setType(AGILENT_CSV.getName());
    file4.setFileStatus(FileStatus.UPLOADED);
    fileSet.add(file4);

    final CaArrayFile file5 = new CaArrayFile();
    file5.setName("file5");
    file5.setFileType(GENEPIX_GAL);
    file5.setFileStatus(FileStatus.UPLOADED);
    fileSet.add(file5);

    final CaArrayFile file6 = new CaArrayFile();
    file6.setName("file6");
    file6.setFileType(null);
    file6.setFileStatus(FileStatus.UPLOADED);
    fileSet.add(file6);

    final CaArrayFile file7 = new CaArrayFile();
    file7.setName("file7");
    file7.setFileType(null);
    file7.setFileStatus(FileStatus.UPLOADING);
    fileSet.add(file7);
    return fileSet;
}

From source file:com.google.gwt.emultest.java.util.TreeSetTest.java

/**
 * Test method for 'java.util.SortedSet.headSet(Object, Object)'.
 *
 * @see java.util.SortedSet#headSet(Object)
 */// w w w  .  ja  v  a  2  s.  com
@SuppressWarnings("unchecked")
public void testHeadMap_throwsClassCastException() {
    SortedSet SortedSet = createNavigableSet();
    SortedSet.add(getKeys()[0]);
    if (isNaturalOrder()) {
        // TODO Why does this succeed with natural ordering when subSet doesn't?
        SortedSet.headSet(getConflictingKey());
    } else {
        try {
            SortedSet.headSet(getConflictingKey());
            assertTrue("CCE expected in Development Mode", !TestUtils.isJvm());
        } catch (ClassCastException e) {
            // expected outcome
        }
    }
}

From source file:com.google.gwt.emultest.java.util.TreeSetTest.java

/**
 * Test method for 'java.util.SortedSet.tailSet(Object, Object)'.
 *
 * @see java.util.SortedSet#tailSet(Object)
 *//*from www.j  a v  a 2 s  . c  om*/
@SuppressWarnings("unchecked")
public void testTailSet_throwsClassCastException() {
    SortedSet SortedSet = createNavigableSet();
    SortedSet.add(getKeys()[0]);
    if (isNaturalOrder()) {
        // TODO Why does this succeed with natural ordering when subSet doesn't?
        SortedSet.tailSet(getConflictingKey());
    } else {
        try {
            SortedSet.tailSet(getConflictingKey());
            assertTrue("CCE expected in Development Mode", !TestUtils.isJvm());
        } catch (ClassCastException e) {
            // expected outcome
        }
    }
}

From source file:com.google.gwt.emultest.java.util.TreeSetTest.java

/**
 * Test method for 'java.util.SortedSet.subSet(Object, Object)'.
 *
 * @see java.util.SortedSet#subSet(Object, Object)
 *///from   w  ww  .  ja  va  2s.  c  o  m
@SuppressWarnings("unchecked")
public void testSubMap_throwsClassCastException() {
    SortedSet SortedSet = createNavigableSet();
    SortedSet.add(getKeys()[0]);
    try {
        SortedSet.subSet(getConflictingKey(), getKeys()[0]);
        assertTrue("CCE expected in Development Mode", !TestUtils.isJvm());
    } catch (IllegalArgumentException e) {
        // since we can't ensure CCEs in Production Mode, we may get IAE
        assertTrue("IllegalArgumentException in Development Mode", !TestUtils.isJvm());
    } catch (ClassCastException e) {
        // expected outcome
    }
    try {
        SortedSet.subSet(getKeys()[0], getConflictingKey());
        assertTrue("CCE expected in Development Mode", !TestUtils.isJvm());
    } catch (IllegalArgumentException e) {
        // since we can't ensure CCEs in Production Mode, we may get IAE
        assertTrue("IllegalArgumentException in Development Mode", !TestUtils.isJvm());
    } catch (ClassCastException e) {
        // expected outcome
    }
}

From source file:fll.scheduler.TournamentSchedule.java

/**
 * Figure out how many performance rounds exist in this header line. This
 * method also checks that the corresponding table header exists for each
 * round and that the round numbers are contiguous starting at 1.
 * /*www .ja  va  2  s.  c  o  m*/
 * @throws FLLRuntimeException if there are problems with the performance
 *           round headers found
 */
private static int countNumRounds(final String[] line) {
    final SortedSet<Integer> perfRounds = new TreeSet<Integer>();
    for (int i = 0; i < line.length; ++i) {
        if (null != line[i] && line[i].startsWith(BASE_PERF_HEADER)
                && line[i].length() > BASE_PERF_HEADER.length()) {
            final String perfNumberStr = line[i].substring(BASE_PERF_HEADER.length());
            final Integer perfNumber = Integer.valueOf(perfNumberStr);
            if (!perfRounds.add(perfNumber)) {
                throw new FLLRuntimeException("Found performance rounds num " + perfNumber
                        + " twice in the header: " + Arrays.asList(line));
            }
        }
    }

    /*
     * check that the values start at 1, are contiguous, and that the
     * corresponding table header exists
     */
    int expectedValue = 1;
    for (Integer value : perfRounds) {
        if (null == value) {
            throw new FLLInternalException("Found null performance round in header!");
        }
        if (expectedValue != value.intValue()) {
            throw new FLLRuntimeException(
                    "Performance rounds not contiguous after " + (expectedValue - 1) + " found " + value);
        }

        final String tableHeader = String.format(TABLE_HEADER_FORMAT, expectedValue);
        if (!checkHeaderExists(line, tableHeader)) {
            throw new FLLRuntimeException("Couldn't find header for round " + expectedValue
                    + ". Looking for header '" + tableHeader + "'");
        }

        ++expectedValue;
    }

    return perfRounds.size();
}

From source file:org.jenkins.tools.test.PluginCompatTester.java

private SortedSet<MavenCoordinates> generateCoreCoordinatesToTest(UpdateSite.Data data,
        PluginCompatReport previousReport) {
    SortedSet<MavenCoordinates> coreCoordinatesToTest = null;
    // If parent GroupId/Artifact are not null, this will be fast : we will only test
    // against 1 core coordinate
    if (config.getParentGroupId() != null && config.getParentArtifactId() != null) {
        coreCoordinatesToTest = new TreeSet<MavenCoordinates>();

        // If coreVersion is not provided in PluginCompatTesterConfig, let's use latest core
        // version used in update center
        String coreVersion = config.getParentVersion() == null ? data.core.version : config.getParentVersion();

        MavenCoordinates coreArtifact = new MavenCoordinates(config.getParentGroupId(),
                config.getParentArtifactId(), coreVersion);
        coreCoordinatesToTest.add(coreArtifact);
        // If parent groupId/artifactId are null, we'll test against every already recorded
        // cores/*from   w  w w. j a  v  a 2s . c o  m*/
    } else if (config.getParentGroupId() == null && config.getParentArtifactId() == null) {
        coreCoordinatesToTest = previousReport.getTestedCoreCoordinates();
    } else {
        throw new IllegalStateException(
                "config.parentGroupId and config.parentArtifactId should either be both null or both filled\n"
                        + "config.parentGroupId=" + String.valueOf(config.getParentGroupId())
                        + ", config.parentArtifactId=" + String.valueOf(config.getParentArtifactId()));
    }

    return coreCoordinatesToTest;
}