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

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

Introduction

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

Prototype

@GwtCompatible(serializable = true)
@Deprecated
public static <T> Ordering<T> from(Ordering<T> ordering) 

Source Link

Document

Simply returns its argument.

Usage

From source file:io.druid.query.groupby.epinephelinae.ByteBufferMinMaxOffsetHeap.java

public ByteBufferMinMaxOffsetHeap(ByteBuffer buf, int limit, Comparator<Integer> minComparator,
        LimitedBufferHashGrouper.BufferGrouperOffsetHeapIndexUpdater heapIndexUpdater) {
    this.buf = buf;
    this.limit = limit;
    this.heapSize = 0;
    this.minComparator = minComparator;
    this.maxComparator = Ordering.from(minComparator).reverse();
    this.heapIndexUpdater = heapIndexUpdater;
}

From source file:org.sonar.server.filters.FilterResult.java

public void sort() {
    if (filter.isSorted()) {
        Comparator<Object[]> comparator = (filter.isTextSort()
                ? new StringIgnoreCaseComparator(SORTED_COLUMN_INDEX)
                : new NumericComparator(SORTED_COLUMN_INDEX));
        if (!filter.isAscendingSort()) {
            comparator = Ordering.from(comparator).reverse();
        }/* w w w .jav a 2  s . c o  m*/
        Collections.sort(rows, comparator);
    }
}

From source file:com.esofthead.mycollab.module.project.ui.components.TimeTrackingUserOrderComponent.java

@Override
protected Ordering<SimpleItemTimeLogging> sortEntries() {
    return Ordering.from(new UserComparator()).compound(new ProjectComparator()).compound(new DateComparator());
}

From source file:org.graylog2.messageprocessors.OrderedMessageProcessors.java

@Inject
public OrderedMessageProcessors(Set<MessageProcessor> processors, ClusterConfigService clusterConfigService,
        EventBus eventBus) {/*  www. j a v  a  2  s .  co m*/
    this.processors = processors;
    this.clusterConfigService = clusterConfigService;
    eventBus.register(this);
    // TODO by default sort on class name this is probably not the best idea, but for now works.
    this.classNameOrdering = Ordering.from(String.CASE_INSENSITIVE_ORDER);

    // Initial sort.
    sortProcessorChain();
}

From source file:net.jamcraft.chowtime.core.client.gui.foodbook.GuiFoodBook.java

@SuppressWarnings("rawtypes")
private void findFoods() {
    Iterator iter = GameData.getItemRegistry().iterator();
    while (iter.hasNext()) {
        Object item = iter.next();
        if (item instanceof ItemFood) {
            if (item instanceof ItemFishFood)
                continue; //for now... ;)
            foods.add((ItemFood) item);//w ww .j  a  va 2s  .c  o  m
        }
    }
    foods = Ordering.from(String.CASE_INSENSITIVE_ORDER).onResultOf(new Function<ItemFood, String>() {
        @Override
        public String apply(ItemFood input) {
            return StatCollector.translateToLocal(input.getUnlocalizedName() + ".name");
        }
    }).immutableSortedCopy(foods);
}

From source file:org.sonar.plugins.web.checks.CheckMessagesVerifier.java

private CheckMessagesVerifier(Collection<Violation> messages) {
    iterator = Ordering.from(ORDERING).sortedCopy(messages).iterator();
}

From source file:org.graylog2.buffers.processors.ServerProcessBufferProcessor.java

@Inject
public ServerProcessBufferProcessor(MetricRegistry metricRegistry, Set<MessageFilter> filterRegistry,
        Configuration configuration, ServerStatus serverStatus, OutputBuffer outputBuffer, Journal journal) {
    super(metricRegistry);
    this.configuration = configuration;
    this.serverStatus = serverStatus;
    this.journal = journal;

    // we need to keep this sorted properly, so that the filters run in the correct order
    this.filterRegistry = Ordering.from(new Comparator<MessageFilter>() {
        @Override/*from w w w .  j  a v a2s .c  om*/
        public int compare(MessageFilter filter1, MessageFilter filter2) {
            return ComparisonChain.start().compare(filter1.getPriority(), filter2.getPriority())
                    .compare(filter1.getName(), filter2.getName()).result();
        }
    }).immutableSortedCopy(filterRegistry);

    this.outputBuffer = outputBuffer;
    this.filteredOutMessages = metricRegistry.meter(name(ProcessBufferProcessor.class, "filteredOutMessages"));
}

From source file:eu.lp0.cursus.scoring.scores.impl.TopCountryOverallPositionData.java

@Override
protected LinkedListMultimap<Integer, Pilot> calculateOverallPositionsWithOrder() {
    if (scores.getRaces().size() < 2) {
        return super.calculateOverallPositionsWithOrder();
    }// w  ww  .ja  v a 2s  .c o m

    Comparator<Pilot> averagePoints = new AveragePointsComparator<T>(scores, placingMethod);
    Comparator<Pilot> racePlacings = new PilotRacePlacingComparator<T>(scores, placingMethod);
    Comparator<Pilot> fallbackOrdering = new PilotRaceNumberComparator();
    SortedSet<Pilot> pilots = new TreeSet<Pilot>(
            Ordering.from(averagePoints).compound(racePlacings).compound(fallbackOrdering));
    pilots.addAll(scores.getPilots());

    LinkedListMultimap<Integer, Pilot> overallPositions = LinkedListMultimap.create();
    List<Pilot> collectedPilots = new ArrayList<Pilot>(scores.getPilots().size());
    int position = 1;

    PeekingIterator<Pilot> it = Iterators.peekingIterator(pilots.iterator());
    while (it.hasNext()) {
        Pilot pilot = it.next();
        collectedPilots.add(pilot);

        // If this pilot compares equally with the next pilot, add them too
        while (it.hasNext() && racePlacings.compare(it.peek(), pilot) == 0) {
            collectedPilots.add(it.next());
        }

        // Sort them by an arbitrary order
        Collections.sort(collectedPilots, fallbackOrdering);

        // Add them all to this position
        overallPositions.putAll(position, collectedPilots);
        position += collectedPilots.size();

        collectedPilots.clear();
    }

    return overallPositions;
}

From source file:com.indeed.lsmtree.core.VolatileGeneration.java

public VolatileGeneration(File logPath, Serializer<K> keySerializer, Serializer<V> valueSerializer,
        Comparator<K> comparator, boolean loadExistingReadOnly) throws IOException {
    this.ordering = Ordering.from(comparator);
    map = new ConcurrentSkipListMap(comparator);
    this.logPath = logPath;
    this.keySerializer = keySerializer;
    this.valueSerializer = valueSerializer;
    deleted = new Object();
    if (loadExistingReadOnly) {
        if (!logPath.exists())
            throw new IllegalArgumentException(logPath.getAbsolutePath() + " does not exist");
        transactionLog = null;// w  w  w .ja  v  a  2  s  . c om
        replayTransactionLog(logPath, true);
    } else {
        if (logPath.exists())
            throw new IllegalArgumentException(
                    "to load existing logs set loadExistingReadOnly to true or create a new log and use replayTransactionLog");
        transactionLog = new TransactionLog.Writer(logPath, keySerializer, valueSerializer, false);
    }
    stuffToClose = SharedReference.create((Closeable) new Closeable() {
        public void close() throws IOException {
            closeWriter();
        }
    });
}

From source file:org.sonar.squidbridge.checks.CheckMessagesVerifier.java

private CheckMessagesVerifier(Collection<CheckMessage> messages) {
    iterator = Ordering.from(ORDERING).sortedCopy(messages).iterator();
}