Example usage for com.google.common.collect Sets newTreeSet

List of usage examples for com.google.common.collect Sets newTreeSet

Introduction

In this page you can find the example usage for com.google.common.collect Sets newTreeSet.

Prototype

public static <E> TreeSet<E> newTreeSet(Comparator<? super E> comparator) 

Source Link

Document

Creates a mutable, empty TreeSet instance with the given comparator.

Usage

From source file:edu.harvard.med.iccbl.screensaver.ui.users.UserAgreementUpdater.java

public UISelectOneBean<ScreensaverUserRole> getNewDataSharingLevel() {
    if (_dataSharingLevel == null) {
        SortedSet<ScreensaverUserRole> candidateDslRoles = Sets
                .newTreeSet(DataSharingLevelMapper.UserDslRoles.get(getScreenType()));
        // At ICCB-L, the RNAi DSL 2 role is not an option, so we hide it at the UI level; we maintain it in our model for consistency with the SM DSL roles
        // TODO: refactor to share this logic with similar code in UserViewer.getNewUserRole()
        if (getApplicationProperties().isFacility(IccblScreensaverConstants.FACILITY_KEY)) {
            candidateDslRoles.remove(ScreensaverUserRole.RNAI_DSL_LEVEL2_MUTUAL_POSITIVES);
        }/*from w  ww .j  a  v  a  2 s  .c o  m*/

        _dataSharingLevel = new UISelectOneBean<ScreensaverUserRole>(candidateDslRoles, DataSharingLevelMapper
                .getPrimaryDataSharingLevelRoleForUser(getScreenType(), _userViewer.getScreeningRoomUser()),
                false) {
            @Override
            protected String makeLabel(ScreensaverUserRole t) {
                return t.getDisplayableRoleName();
            }
        };
    }
    return _dataSharingLevel;
}

From source file:org.openqa.selenium.android.intents.IntentReceiver.java

private Set<String> getActiveKeys(Bundle extras) {
    Set<String> keys = extras.keySet();
    // Remove this from the key set as it is only used to detect parcels
    keys.remove(IntentSender.IS_PARCELABLE);
    return Sets.newTreeSet(keys); // keeps the keys sorted.
}

From source file:kr.co.vcnc.haeinsa.HaeinsaPut.java

/**
 * Creates an empty set if one doesn't exist for the given column family or
 * else it returns the associated set of KeyValue objects.
 *
 * @param family column family/*from ww  w  .  j a  v a 2 s.  c o  m*/
 * @return a set of KeyValue objects, returns an empty set if one doesn't
 * exist.
 */
private NavigableSet<HaeinsaKeyValue> getKeyValueSet(byte[] family) {
    NavigableSet<HaeinsaKeyValue> set = familyMap.get(family);
    if (set == null) {
        set = Sets.newTreeSet(HaeinsaKeyValue.COMPARATOR);
    }
    return set;
}

From source file:com.clarkparsia.versioning.ui.HistoryList.java

private void addHistory(Revision head) {
    Set<Ref> revisions = Sets.newTreeSet(NEWEST_FIRST);
    Queue<Revision> pending = Lists.newLinkedList();
    pending.add(head);//from ww w . ja v a2 s.c om
    while (!pending.isEmpty()) {
        Revision rev = pending.remove();
        revisions.add(rev);
        if (showBranches) {
            revisions.add(rev.getBranch());
        }
        pending.addAll(rev.getParents());
    }

    for (Ref rev : revisions) {
        add(rev);
    }
}

From source file:com.spotify.apollo.request.RequestRunnableImpl.java

private void matchAndRun(BiConsumer<OngoingRequest, RuleMatch<Endpoint>> matchContinuation) {
    final Request request = ongoingRequest.request();
    final Optional<RuleMatch<Endpoint>> match;

    try {//from   w  ww  .j ava 2 s  . co  m
        match = applicationRouter.match(request);
    } catch (InvalidUriException e) {
        LOG.warn("bad uri {} {} {}", request.method(), request.uri(), BAD_REQUEST, e);
        ongoingRequest.reply(forStatus(BAD_REQUEST));
        return;
    }

    if (!match.isPresent()) {
        Collection<String> methods = applicationRouter.getMethodsForValidRules(request);
        if (methods.isEmpty()) {
            LOG.warn("not found {} {} {}", request.method(), request.uri(), NOT_FOUND);
            ongoingRequest.reply(forStatus(NOT_FOUND));
        } else {
            StatusType statusCode;
            if ("OPTIONS".equals(request.method())) {
                statusCode = NO_CONTENT;
            } else {
                statusCode = METHOD_NOT_ALLOWED;
                LOG.warn("wrong method {} {} {}", request.method(), request.uri(), statusCode);
            }
            methods = Sets.newTreeSet(methods);
            methods.add("OPTIONS");
            ongoingRequest.reply(Response.<ByteString>forStatus(statusCode).withHeader("Allow",
                    Joiner.on(", ").join(methods)));
        }
        return;
    }

    matchContinuation.accept(ongoingRequest, match.get());
}

From source file:org.jclouds.codegen.ec2.queryapi.parser.AmazonEC2QueryAPIValidator.java

protected AmazonEC2QueryAPIValidator validateDataType(DataType dataType) {
    checkState(dataType.getSee().size() >= 1, "see should have at least one entry");
    Set<String> fieldNames = Sets
            .newTreeSet(Iterables.transform(dataType.getContents(), new Function<Content, String>() {
                public String apply(Content field) {
                    return field.getName();
                }//from  w ww  . j  a va2s  .  c  o m
            }));
    checkState(
            Sets.difference(fieldNames, expectedFieldNamesForDataTypeName.get(dataType.getType())).size() == 0,
            String.format("%1$s hasn't the correct fields.  has [%2$s] should have [%3$s]", dataType.getType(),
                    fieldNames, expectedFieldNamesForDataTypeName.get(dataType.getType())));
    return this;
}

From source file:org.kuali.rice.xml.ingest.RiceConfigUtils.java

public static void override(Properties oldProps, Properties newProps) {
    SortedSet<String> commonKeys = Sets
            .newTreeSet(Sets.intersection(newProps.stringPropertyNames(), oldProps.stringPropertyNames()));
    if (commonKeys.size() == 0) {
        return;/*from w ww. ja va2  s.c o  m*/
    }
    logger.debug("{} keys in common", commonKeys.size());
    for (String commonKey : commonKeys) {
        String oldValue = oldProps.getProperty(commonKey);
        String newValue = newProps.getProperty(commonKey);
        if (!newValue.equals(oldValue)) {
            Object[] args = { commonKey, toLogMsg(commonKey, oldValue), toLogMsg(commonKey, newValue) };
            logger.info("Overriding - [{}]=[{}]->[{}]", args);
            oldProps.setProperty(commonKey, newValue);
        }
    }
}

From source file:edu.washington.cs.cupid.internal.CapabilityRegistry.java

@Override
public synchronized SortedSet<ICapability> getCapabilitiesForOutput(final TypeToken<?> outputType) {
    SortedSet<ICapability> result = Sets.newTreeSet(CapabilityUtil.COMPARE_NAME);

    for (ICapability capability : capabilities) {
        for (ICapability.IOutput<?> output : capability.getOutputs()) {
            if (TypeManager.isJavaCompatible(outputType, output.getType())) {
                result.add(capability);/*from   w w w.j av  a2s. co  m*/
                break;
            }
        }
    }
    return result;
}

From source file:de.tu_berlin.dima.oligos.stat.distribution.histogram.Histograms.java

public static <T> SortedSet<T> collectElementsInRange(Bucket<T> bucket, Map<T, Long> mostFrequent,
        Operator<T> operator) {/*  w  w w.java2s  .c o m*/
    SortedSet<T> elemsInRange = Sets.newTreeSet(operator);
    for (T elem : mostFrequent.keySet()) {
        if (isInBucket(bucket, elem, operator)) {
            elemsInRange.add(elem);
        }
    }
    return elemsInRange;
}

From source file:org.fenixedu.learning.domain.degree.components.DegreeClassesComponent.java

private SortedMap<Integer, Set<SchoolClass>> classesByCurricularYear(Degree degree,
        ExecutionSemester semester) {/*  w  w  w.ja  va  2 s.c o  m*/
    DegreeCurricularPlan plan = DegreeCurricularPlanServices.getMostRecentDegreeCurricularPlan(degree,
            Optional.of(semester.getExecutionYear()));
    Predicate<SchoolClass> predicate = schoolClass -> schoolClass.getExecutionDegree()
            .getDegreeCurricularPlan() == plan;
    return semester.getSchoolClassesSet().stream().filter(predicate)
            .collect(groupingBy(SchoolClass::getAnoCurricular, TreeMap::new,
                    toCollection(() -> Sets.newTreeSet(COMPARATOR_BY_NAME))));
}