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(SortedSet<E> s) 

Source Link

Document

Constructs a new tree set containing the same elements and using the same ordering as the specified sorted set.

Usage

From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.executionDegree.ExecutionDegreesForDegreeCurricularPlan.java

@Override
public Object provide(Object source, Object currentValue) {
    Set<ExecutionDegree> result = new TreeSet<ExecutionDegree>(
            new ReverseComparator(ExecutionDegree.EXECUTION_DEGREE_COMPARATORY_BY_YEAR));

    ExecutionDegreeBean executionDegreeBean = (ExecutionDegreeBean) source;
    DegreeCurricularPlan degreeCurricularPlan = executionDegreeBean.getDegreeCurricularPlan();

    if (degreeCurricularPlan != null) {
        result.addAll(degreeCurricularPlan.getExecutionDegreesSet());
    }//ww  w .  ja  v a 2 s . c o m

    return result;
}

From source file:com.pc.dailymile.domain.Friends.java

public void setFriends(Set<User> friends) {
    this.friends = new TreeSet<User>(friends);
}

From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.candidacy.ExecutionYearsForDegree.java

@Override
public Object provide(Object source, Object currentValue) {
    final SortedSet<ExecutionYear> result = new TreeSet<ExecutionYear>(
            new ReverseComparator(ExecutionYear.COMPARATOR_BY_YEAR));

    final DFACandidacyBean bean = (DFACandidacyBean) source;
    if (bean.getDegree() != null) {
        for (final DegreeCurricularPlan dcp : bean.getDegree().getDegreeCurricularPlansSet()) {
            result.addAll(dcp.getExecutionYears());
        }/*w w  w.  j  av  a 2 s . co  m*/
    } else {
        bean.setExecutionYear(null);
    }
    return result;
}

From source file:delfos.rs.trustbased.belieffunctions.BeliefFunction.java

@Override
public boolean equals(Object obj) {

    if (obj instanceof BeliefFunction) {

        BeliefFunction beliefFunction = (BeliefFunction) obj;

        Set<Parameter> thisParameters = new TreeSet<Parameter>(this.getParameters());
        Set<Parameter> otherParameters = new TreeSet<Parameter>(beliefFunction.getParameters());

        EqualsBuilder equalsBuilder = new EqualsBuilder();

        equalsBuilder = equalsBuilder.append(this.getClass(), beliefFunction.getClass()).append(thisParameters,
                otherParameters);/*w w  w.  j a  v  a 2s .c o  m*/

        return equalsBuilder.isEquals();
    } else {
        return false;
    }

}

From source file:com.erinors.hpb.server.handler.SortedSetHandler.java

@Override
public Object clone(CloningContext context, Object object) {
    if (!(object instanceof SortedSet)) {
        return null;
    }// w w w .ja v  a 2  s  . com

    SortedSet<Object> source = (SortedSet<Object>) object;
    SortedSet<Object> result;

    if (source instanceof PersistentSortedSet && !((PersistentSortedSet) source).wasInitialized()) {
        result = new UninitializedPersistentSortedSet<Object>(source.comparator());
        context.addProcessedObject(object, result);
    } else {
        SortedSet<Object> set = new TreeSet<Object>(source.comparator());
        context.addProcessedObject(object, set);

        for (Object element : source) {
            set.add(context.clone(element));
        }

        result = set;
    }

    return result;
}

From source file:io.syndesis.dao.ReadApiClientDataTest.java

@Test
public void deserializeModelDataTest() throws IOException {

    Integration integrationIn = new Integration.Builder().desiredStatus(Integration.Status.Activated)
            .tags(new TreeSet<>(Arrays.asList("tag1", "tag2"))).createdDate(new Date()).build();
    String integrationJson = mapper.writeValueAsString(integrationIn);
    System.out.println(integrationJson);
    Integration integrationOut = mapper.readValue(integrationJson, Integration.class);
    Assert.assertEquals(integrationIn.getDesiredStatus(), integrationOut.getDesiredStatus());

    //serialize//  www . j a  v  a2 s.c o m
    ConnectorGroup cg = new ConnectorGroup.Builder().id("label").name("label").build();
    ModelData<ConnectorGroup> mdIn = new ModelData<>(Kind.ConnectorGroup, cg);
    Assert.assertEquals("{\"id\":\"label\",\"name\":\"label\"}", mdIn.getDataAsJson());

    //deserialize
    String json = mapper.writeValueAsString(mdIn);
    ModelData<?> mdOut = mapper.readValue(json, ModelData.class);
    Assert.assertEquals("{\"id\":\"label\",\"name\":\"label\"}", mdOut.getDataAsJson());
}

From source file:edu.cornell.mannlib.vitro.webapp.utils.log.LogUtils.java

private String requestProperties(HttpServletRequest req) {
    @SuppressWarnings("unchecked")
    Map<String, String[]> map = req.getParameterMap();

    String s = req.getRequestURL().append('\n').toString();
    for (String name : new TreeSet<String>(map.keySet())) {
        s += "   " + name + " = " + Arrays.toString(map.get(name)) + '\n';
    }//www .  j  a va 2 s.c  om
    return s.trim();
}

From source file:org.jasig.portlet.test.web.TestPickerInterceptor.java

@Autowired
public void setPortletTests(Collection<PortletTest> portletTests) {
    final Set<PortletTest> newPortletTests = new TreeSet<PortletTest>(PortletTestComparator.INSTANCE);
    newPortletTests.addAll(portletTests);

    this.portletTests = newPortletTests;
}

From source file:org.atemsource.atem.impl.infrastructure.HandlerLocatorImpl.java

private void addBean(Bean<H> bean, Class<T> modelType) {
    SortedSet<Bean<H>> SortedSet = sortedTypeHandlerBeans.get(modelType);
    if (SortedSet == null) {
        SortedSet = new TreeSet<Bean<H>>(new OrderComparator());
        sortedTypeHandlerBeans.put(modelType, SortedSet);
    }/*  w w  w. jav a 2s .com*/
    SortedSet.add(bean);
}

From source file:com.vrem.wifianalyzer.wifi.graphutils.SeriesCache.java

List<WiFiDetail> difference(@NonNull Set<WiFiDetail> series) {
    Set<WiFiDetail> difference = new TreeSet<>(cache.keySet());
    difference.removeAll(series);/*  ww w .  j av a2s. c  o  m*/
    return new ArrayList<>(difference);
}