Example usage for java.util TreeSet TreeSet

List of usage examples for java.util TreeSet TreeSet

Introduction

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

Prototype

public TreeSet() 

Source Link

Document

Constructs a new, empty tree set, sorted according to the natural ordering of its elements.

Usage

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:org.bedework.eventreg.web.AdminAgendaController.java

@Override
public ModelAndView doRequest() throws Throwable {
    sessMan.flushCurrEvent();//ww  w.  j a  v  a  2 s .  c om
    final Event ev = sessMan.getCurrEvent();

    final TreeSet<Registration> regs = new TreeSet<>();

    for (final Registration reg : sessMan.getRegistrationsByHref(ev.getHref())) {
        reg.setEvent(ev);

        regs.add(reg);
    }

    return objModel("adminagenda", "regs", regs);
}

From source file:br.edu.ifpb.pos.command.Commands.java

public Group createOptions() {
    Option help = obuilder.withLongName("help").withDescription("Ajuda para o usurio").create();
    ////w ww. j  a v  a 2 s . co m
    Set<String> typeEntity = new TreeSet();
    typeEntity.add("json_person");
    typeEntity.add("json_user");
    EnumValidator enumValidator = new EnumValidator(typeEntity);

    Option type = obuilder
            .withLongName("type").withDescription("Tipo de Objeto a ser salvo").withArgument(abuilder
                    .withMaximum(1).withMinimum(1).withName("type").withValidator(enumValidator).create())
            .create();
    //
    Group groupType = gbuilder.withOption(type).withMaximum(1).withMinimum(1).withRequired(true).create();
    //
    Argument argument = abuilder.withName("json_object").withMaximum(1).withMinimum(1).create();
    //
    Option insert = obuilder.withLongName("insert")
            .withDescription("Insere um novo objeto em formarto JSON de acordo com os atributos da entidade")
            .withChildren(groupType).withArgument(argument).create();
    Option delete = obuilder.withLongName("delete")
            .withDescription("Exclui um objeto passando a chave da entidade nesse formato: {\"key\": value}")
            .withArgument(argument).withChildren(groupType).create();
    Option update = obuilder.withLongName("update").withDescription(
            "Atualiza um objeto em formarto JSON de acordo com esse formato: {\"key\": value, outros parametros...}")
            .withArgument(argument).withChildren(groupType).create();

    Group crudGroup = gbuilder.withOption(update).withOption(insert).withOption(delete).withRequired(true)
            .create();

    Option select = obuilder.withLongName("select")
            .withDescription("Visualiza um objeto passando a chave da entidade nesse formato: {\"key\": value}")
            .withArgument(argument).withChildren(groupType).create();

    Group group = gbuilder.withOption(help).withOption(crudGroup).withOption(select).create();

    return group;
}

From source file:com.mycsense.carbondb.domain.SingleElement.java

public SingleElement() {
    keywords = new TreeSet<>();
}

From source file:com.fileanalyzer.util.LineStatisticCalculator.java

public FileStatistic getFileStatistic() {
    FileStatistic fileStatis = new FileStatistic();

    fileStatis.setLengthLine(new Long(line.length()));
    String strArr[] = line.split(regexp);
    TreeSet<Integer> maxWord = new TreeSet();
    TreeSet<Integer> minWord = new TreeSet();
    long sumWords = 0;
    for (int i = 0; i < strArr.length; ++i) {
        int strSize = strArr[i].length();
        sumWords += strSize;//  w ww .  ja  v  a  2 s .c o m
        if (i > 0 && i < strArr.length - 1)
            maxWord.add(strSize);
        minWord.add(strSize);
    }
    fileStatis.setLine(HtmlUtils.htmlEscape(line));
    if (sumWords > 0) {
        fileStatis.setAvgWord(new Double(sumWords / strArr.length));
        fileStatis.setMinWord(new Long(minWord.first()));
    }
    if (maxWord.size() > 0)
        fileStatis.setMaxWord(new Long(maxWord.last()));
    if (getIdFk() != null)
        fileStatis.setFileId(getIdFk());
    return fileStatis;
}

From source file:edu.temple.cis3238.wiki.utils.CollectionsUtilitiesTest.java

/**
 * Test of filterList+ pluck methods of class CollectionsUtilities.
 *//*ww  w .  j a v a 2 s. com*/
@Test
public void testFilterList() {
    Set<String> actualSet = new TreeSet<String>();
    ;
    System.out.println(
            "pluck column from Object and return CSV" + "\n=======================================\n\n");
    GeneralDAO dao = new GeneralDAO(dbc);
    Set expResult = null;

    ArrayList<TagsVO> tagVOLIst;
    String expected = "";
    String actual;

    tagVOLIst = dao.getTags();
    Collections.sort(tagVOLIst);
    for (int i = 0; i < tagVOLIst.size(); i++) {
        expected += tagVOLIst.get(i).getTagName();
        if (i < tagVOLIst.size() - 1) {
            expected += ",";
        }
    }
    Set<String> result = CollectionsUtilities.pluckList(tagVOLIst, "tagname");
    actualSet.addAll(result);

    actual = setToCSV(result);

    System.out.println("====================\nactual" + "\n------------------------------------\n" + actual
            + "\n------------------------------------\n");

    System.out.println("====================\nexpected" + "\n------------------------------------\n" + expected
            + "\n------------------------------------\n");

    assertEquals(result, actualSet);
}

From source file:edu.gatech.i3l.fhir.jpa.provider.BaseJpaProvider.java

public void startRequest(HttpServletRequest theRequest) {
    if (theRequest == null) {
        return;/*from   ww w  . jav  a2s .c om*/
    }

    Set<String> headerNames = new TreeSet<String>();
    for (Enumeration<String> enums = theRequest.getHeaderNames(); enums.hasMoreElements();) {
        headerNames.add(enums.nextElement());
    }
    ourLog.debug("Request headers: {}", headerNames);

    Enumeration<String> forwardedFors = theRequest.getHeaders("x-forwarded-for");
    StringBuilder b = new StringBuilder();
    for (Enumeration<String> enums = forwardedFors; enums.hasMoreElements();) {
        if (b.length() > 0) {
            b.append(" / ");
        }
        b.append(enums.nextElement());
    }

    String forwardedFor = b.toString();
    String ip = theRequest.getRemoteAddr();
    if (StringUtils.isBlank(forwardedFor)) {
        org.slf4j.MDC.put(REMOTE_ADDR, ip);
        ourLog.debug("Request is from address: {}", ip);
    } else {
        org.slf4j.MDC.put(REMOTE_ADDR, forwardedFor);
        ourLog.debug("Request is from forwarded address: {}", forwardedFor);
    }

    String userAgent = StringUtils.defaultString(theRequest.getHeader("user-agent"));
    org.slf4j.MDC.put(REMOTE_UA, userAgent);

}

From source file:com.github.fritaly.dualcommander.SortedListModel.java

public SortedListModel() {
    // Use the natural order
    this.model = new TreeSet<E>();
}

From source file:de.shadowhunt.sonar.plugins.ignorecode.model.CoveragePatternTest.java

@Test
public void testAddLine() throws Exception {
    final SortedSet<Integer> lines = new TreeSet<>();
    lines.add(1);/*from w ww . j  a  v  a  2s  . c  om*/
    lines.add(3);
    lines.add(5);
    final CoveragePattern pattern = new CoveragePattern("resourcePattern", lines);

    final SortedSet<Integer> full = pattern.getLines();
    Assert.assertNotNull("SortedSet must not be null", full);
    Assert.assertEquals("SortedSet must contain the exact number of entries", 3, full.size());
    Assert.assertTrue("SortedSet must contain line 1", full.contains(1));
    Assert.assertTrue("SortedSet must contain line 3", full.contains(3));
    Assert.assertTrue("SortedSet must contain line 5", full.contains(5));
}

From source file:com.technicolor.qeo.codegen.type.tsm.TsmMember.java

/**
 * Create a CTsmMember object.// w w  w .  j  a va 2  s.  co m
 * 
 * @param name Member name
 */
public TsmMember(String name) {
    super(name);
    mFlags = new TreeSet<String>();
    mSeq = new ArrayList<TsmMember>();
}