Example usage for com.google.common.collect Ordering natural

List of usage examples for com.google.common.collect Ordering natural

Introduction

In this page you can find the example usage for com.google.common.collect Ordering natural.

Prototype

@GwtCompatible(serializable = true)
@SuppressWarnings("unchecked") 
public static <C extends Comparable> Ordering<C> natural() 

Source Link

Document

Returns a serializable ordering that uses the natural order of the values.

Usage

From source file:org.jasig.portlet.blackboardvcportlet.mvc.sessionmngr.SessionDisplayComparator.java

@Override
public int compare(Session o1, Session o2) {
    return ComparisonChain.start().compare(o2.getStartTime(), o1.getStartTime(), Ordering.natural().nullsLast())
            .compare(o1.getSessionName(), o2.getSessionName(), Ordering.natural().nullsLast()).result();
}

From source file:org.eclipse.sirius.diagram.sequence.business.internal.RangeHelper.java

/**
 * Returns an ordering suitable to sort ranges by their upper bound.
 * /*  ww  w . ja v  a  2s  .  c om*/
 * @return an ordering suitable to sort ranges by their upper bound.
 */
public static Ordering<Range> upperBoundOrdering() {
    return Ordering.natural().onResultOf(RangeHelper.upperBoundFunction());
}

From source file:org.apache.druid.query.aggregation.TimestampMaxAggregatorFactory.java

@JsonCreator
public TimestampMaxAggregatorFactory(@JsonProperty("name") String name,
        @JsonProperty("fieldName") String fieldName, @JsonProperty("timeFormat") String timeFormat) {
    super(name, fieldName, timeFormat, Ordering.natural(), Long.MIN_VALUE);
    Preconditions.checkNotNull(name, "Must have a valid, non-null aggregator name");
    Preconditions.checkNotNull(fieldName, "Must have a valid, non-null fieldName");
}

From source file:org.apache.druid.query.aggregation.TimestampMinAggregatorFactory.java

@JsonCreator
public TimestampMinAggregatorFactory(@JsonProperty("name") String name,
        @JsonProperty("fieldName") String fieldName, @JsonProperty("timeFormat") String timeFormat) {
    super(name, fieldName, timeFormat, Ordering.natural().reverse(), Long.MAX_VALUE);
    Preconditions.checkNotNull(name, "Must have a valid, non-null aggregator name");
    Preconditions.checkNotNull(fieldName, "Must have a valid, non-null fieldName");
}

From source file:org.jasig.portlet.blackboardvcportlet.mvc.sessionmngr.MultimediaDisplayComparator.java

@Override
public int compare(Multimedia o1, Multimedia o2) {
    return ComparisonChain.start().compare(o1.getFilename(), o2.getFilename(), Ordering.natural().nullsLast())
            .compare(o1.getLastUpdated(), o2.getLastUpdated(), Ordering.natural().nullsLast()).result();
}

From source file:io.v.chat.ParticipantsPanel.java

public void setParticipants(List<Participant> participants) {
    participantTextArea.clear();//from  w w w . ja  v a 2  s .  c o m
    boolean first = true;
    Function<Participant, String> nameFunction = new Function<Participant, String>() {
        @Override
        public String apply(Participant input) {
            return input.getName();
        }
    };
    for (String participant : Ordering.natural().sortedCopy(Iterables.transform(participants, nameFunction))) {
        if (first) {
            participantTextArea.setLine(0, participant);
            first = false;
        } else {
            participantTextArea.appendLine(participant);
        }
    }
}

From source file:org.atlasapi.util.stats.Count.java

@SuppressWarnings("unchecked")
public Count(T target, int score) {
    this(target, (Comparator<? super T>) Ordering.natural(), score);
    if (!(target instanceof Comparable<?>)) {
        throw new IllegalArgumentException(
                "Count requires that targets implement Comparable or provide a suitable Comparator");
    }/*from w w  w.j a  v  a 2  s.com*/
}

From source file:org.jasig.portlet.blackboardvcportlet.mvc.sessionmngr.SessionRecordingDisplayComparator.java

@Override
public int compare(SessionRecording o1, SessionRecording o2) {
    return ComparisonChain.start().compare(o1.getRoomStart(), o2.getRoomStart(), Ordering.natural().nullsLast())
            .compare(o1.getRoomName(), o2.getRoomName(), Ordering.natural().nullsLast()).result();
}

From source file:org.haiku.haikudepotserver.pkg.model.PkgIconConfiguration.java

@Override
public int compareTo(PkgIconConfiguration o) {
    return ComparisonChain.start().compare(o.getMediaType().getCode(), getMediaType().getCode())
            .compare(o.getSize(), getSize(), Ordering.natural().nullsFirst()).result();
}

From source file:org.jasig.portlet.blackboardvcportlet.mvc.sessionmngr.ConferenceUserDisplayComparator.java

@Override
public int compare(ConferenceUser o1, ConferenceUser o2) {
    return ComparisonChain.start()
            .compare(o1.getDisplayName(), o2.getDisplayName(), Ordering.natural().nullsLast()).result();
}