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:jenkins.scm.impl.subversion.SubversionSCMSource.java

/**
 * Splits a set of path strings into a set of lists of path segments.
 *
 * @param pathStrings the set of path strings.
 * @return the set of lists of path segments.
 *///w w  w  .j a v  a  2  s.  c  om
@NonNull
static SortedSet<List<String>> toPaths(@NonNull SortedSet<String> pathStrings) {
    SortedSet<List<String>> result = new TreeSet<List<String>>(COMPARATOR);
    for (String clude : pathStrings) {
        result.add(Arrays.asList(clude.split("/")));
    }
    return result;
}

From source file:com.cloudera.whirr.cm.CmServerClusterInstance.java

@SuppressWarnings("unchecked")
public static SortedSet<String> getMounts(ClusterSpec specification, Set<Instance> instances)
        throws IOException {
    Configuration configuration = getConfiguration(specification);
    SortedSet<String> mounts = new TreeSet<String>();
    Set<String> deviceMappings = CmServerClusterInstance.getDeviceMappings(specification, instances).keySet();
    if (!configuration.getList(CONFIG_WHIRR_DATA_DIRS_ROOT).isEmpty()) {
        mounts.addAll(configuration.getList(CONFIG_WHIRR_DATA_DIRS_ROOT));
    } else if (!deviceMappings.isEmpty()) {
        mounts.addAll(deviceMappings);/* w  w w . j  a va  2 s .  c om*/
    } else {
        mounts.add(configuration.getString(CONFIG_WHIRR_INTERNAL_DATA_DIRS_DEFAULT));
    }
    return mounts;
}

From source file:io.syndesis.runtime.JsonHandlingITCase.java

@Test
public void valuesGivenInJsonShouldBeTrimmedToNull() {
    final SortedSet<String> tags = new TreeSet<>();
    tags.add("");
    tags.add(" tag");
    tags.add("\tTaggy McTagface\t");

    final Integration integration = new Integration.Builder().id(id).name("  some-name\t").description("")
            .tags(tags).desiredStatus(Integration.Status.Draft).build();
    post("/api/v1/integrations", integration, Integration.class);

    final ResponseEntity<Integration> result = get("/api/v1/integrations/" + id, Integration.class);
    final Integration created = result.getBody();
    assertThat(created.getName()).isEqualTo("some-name");
    assertThat(created.getDescription()).isNotPresent();
    assertThat(created.getTags()).containsExactly("Taggy McTagface", "tag");

}

From source file:fr.imag.model2roo.addon.graph.NodeIdTypeConverter.java

public boolean getAllPossibleValues(final List<Completion> completions, final Class<?> targetType,
        final String existingData, final String optionContext, final MethodTarget target) {
    final SortedSet<String> types = new TreeSet<String>();
    types.add(Long.class.getName());

    for (final String type : types) {
        if (type.startsWith(existingData) || existingData.startsWith(type)) {
            completions.add(new Completion(type));
        }// w  w w . j  a  v  a2s. c  o m
    }
    return false;
}

From source file:Main.java

private SortedSet<Integer> getSet(String str) {
    SortedSet<Integer> result = new TreeSet<Integer>();
    StringTokenizer st = new StringTokenizer(str, " ");
    while (st.hasMoreTokens()) {
        result.add(Integer.valueOf(st.nextToken()));
    }/*from   w  w w .j  a  va 2 s. c  o m*/
    return result;
}

From source file:jenkins.scm.impl.subversion.SubversionSCMSource.java

/**
 * Filters the set of path segments, retaining only those that start with the supplied prefix.
 *
 * @param pathSegments the set of path segments.
 * @param prefix       the prefix./*from  w w  w .  ja  v a 2s .c om*/
 * @return a new set of path segments.
 */
@NonNull
static SortedSet<List<String>> filterPaths(@NonNull SortedSet<List<String>> pathSegments,
        @NonNull List<String> prefix) {
    SortedSet<List<String>> result = new TreeSet<List<String>>(COMPARATOR);
    for (List<String> pathSegment : pathSegments) {
        if (startsWith(pathSegment, prefix)) {
            result.add(pathSegment);
        }
    }
    return result;
}

From source file:com.espertech.esper.schedule.TestScheduleSpec.java

public void testValidate() {
    // Test all units missing
    EnumMap<ScheduleUnit, SortedSet<Integer>> unitValues = new EnumMap<ScheduleUnit, SortedSet<Integer>>(
            ScheduleUnit.class);
    assertInvalid(unitValues);//  ww w  . j  a v  a 2s  .c om

    // Test one unit missing
    unitValues = (new ScheduleSpec()).getUnitValues();
    unitValues.remove(ScheduleUnit.HOURS);
    assertInvalid(unitValues);

    // Test all units are wildcards
    unitValues = (new ScheduleSpec()).getUnitValues();
    new ScheduleSpec(unitValues, null, null, null);

    // Test invalid value in month
    SortedSet<Integer> values = new TreeSet<Integer>();
    values.add(0);
    unitValues.put(ScheduleUnit.MONTHS, values);
    assertInvalid(unitValues);

    // Test valid value in month
    values = new TreeSet<Integer>();
    values.add(1);
    values.add(5);
    unitValues.put(ScheduleUnit.MONTHS, values);
    new ScheduleSpec(unitValues, null, null, null);
}

From source file:am.ik.categolj2.domain.model.CategoryTest.java

@Test
public void testInTreeSet() {
    Category c1 = new Category(1, 1, "Programmming");
    Category c2 = new Category(1, 2, "Java");
    Category c3 = new Category(1, 3, "org");
    Category c4 = new Category(2, 4, "springframework");
    Category c5 = new Category(1, 5, "core");
    SortedSet<Category> categories = new TreeSet<Category>();

    // added randomly
    categories.add(c3);
    categories.add(c1);/*from w ww . j  a va2 s . com*/
    categories.add(c5);
    categories.add(c2);
    categories.add(c4);

    Iterator<Category> iterator = categories.iterator();

    assertThat(iterator.next(), is(c1));
    assertThat(iterator.next(), is(c2));
    assertThat(iterator.next(), is(c3));
    assertThat(iterator.next(), is(c4));
    assertThat(iterator.next(), is(c5));
}

From source file:com.collective.celos.servlet.JSONWorkflowListServlet.java

ObjectNode createJSONObject(WorkflowConfiguration cfg) {
    // Make sure the IDs are sorted
    SortedSet<String> ids = new TreeSet<String>();
    for (Workflow wf : cfg.getWorkflows()) {
        ids.add(wf.getID().toString());
    }//from  ww  w . ja v a 2s.c om
    ArrayNode list = Util.MAPPER.createArrayNode();
    for (String id : ids) {
        list.add(id);
    }
    ObjectNode object = Util.MAPPER.createObjectNode();
    object.put(CelosClient.IDS_PARAM, list);
    return object;
}

From source file:org.sventon.util.HTMLCreatorTest.java

@Test
public void testCreateChangedPathsTable() throws Exception {
    final String result = "<table class=\"changedPathsTable\">\n" + "  <tr>\n"
            + "    <th align=\"left\">Action</th>\n" + "    <th align=\"left\">Path</th>\n" + "  </tr>\n"
            + "  <tr>\n" + "    <td valign=\"top\"><i>Modified</i></td>\n"
            + "    <td><a href=\"repos/sandbox/diff/file1.java?revision=1&entries=/file1.java@1&entries=/file1.java@0\" title=\"Diff with previous version\"><i>/file1.java</i></a></td>\n"
            + "  </tr>\n" + "  <tr>\n" + "    <td valign=\"top\"><i>Deleted</i></td>\n"
            + "    <td><a href=\"repos/sandbox/goto/file2.html?revision=0\" title=\"Show previous revision\"><del>/file2.html</del></a></td>\n"
            + "  </tr>\n" + "  <tr>\n" + "    <td valign=\"top\"><i>Added</i></td>\n"
            + "    <td><a href=\"repos/sandbox/goto/file3.abc?revision=1\" title=\"Show\">/file3.abc</a><br>(<i>Copy from</i> <a href=\"repos/sandbox/goto/branch/file3.abc?revision=1\" title=\"Show\">/branch/file3.abc</a> @ <a href=\"repos/sandbox/info?revision=1\">1</a>)</td>\n"
            + "  </tr>\n" + "  <tr>\n" + "    <td valign=\"top\"><i>Replaced</i></td>\n"
            + "    <td><a href=\"repos/sandbox/goto/file4.def?revision=1\" title=\"Show\">/file4.def</a></td>\n"
            + "  </tr>\n" + "</table>";

    final SortedSet<ChangedPath> changedPaths = new TreeSet<ChangedPath>();
    changedPaths.add(new ChangedPath("/file1.java", null, 1, ChangeType.MODIFIED));
    changedPaths.add(new ChangedPath("/file2.html", null, 1, ChangeType.DELETED));
    changedPaths.add(new ChangedPath("/file3.abc", "/branch/file3.abc", 1, ChangeType.ADDED));
    changedPaths.add(new ChangedPath("/file4.def", null, 1, ChangeType.REPLACED));

    final LogEntry logEntry = TestUtils.createLogEntry(1, "jesper", new Date(), "Testing", changedPaths);

    assertEquals(result, HTMLCreator.createChangedPathsTable(logEntry.getChangedPaths(), logEntry.getRevision(),
            "/file1.java", "", new RepositoryName("sandbox"), false, false, new MockHttpServletResponse()));
}