Java Code Examples for com.google.common.primitives.Longs#compare()

The following examples show how to use com.google.common.primitives.Longs#compare() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: The-5zig-Mod   File: Friend.java    License: MIT License 5 votes vote down vote up
@Override
public int compareTo(Friend friend) {
	if (friend.isFavorite() && !isFavorite())
		return 1;
	if (isFavorite() && !friend.isFavorite())
		return -1;
	if (The5zigMod.getConfig().getEnum("friendSortation", Sortation.class) == Sortation.ONLINE) {
		if (getStatus() != friend.getStatus() && (getStatus() != OnlineStatus.OFFLINE || friend.getStatus() != OnlineStatus.OFFLINE)) {
			return getStatus().compareTo(friend.getStatus());
		} else if (getStatus() == OnlineStatus.OFFLINE && friend.getStatus() == OnlineStatus.OFFLINE) {
			return Longs.compare(friend.lastOnline, lastOnline);
		}
	}
	return getUsername().toLowerCase(Locale.ROOT).compareTo(friend.getUsername().toLowerCase(Locale.ROOT));
}
 
Example 2
Source Project: phoenix   File: PLong.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int compareTo(Object lhs, Object rhs, PDataType rhsType) {
  if (rhsType == PDecimal.INSTANCE) {
    return -((BigDecimal) rhs).compareTo(BigDecimal.valueOf(((Number) lhs).longValue()));
  } else if (equalsAny(rhsType, PDouble.INSTANCE, PFloat.INSTANCE, PUnsignedDouble.INSTANCE, PUnsignedFloat.INSTANCE)) {
    return Doubles.compare(((Number) lhs).doubleValue(), ((Number) rhs).doubleValue());
  }
  return Longs.compare(((Number) lhs).longValue(), ((Number) rhs).longValue());
}
 
Example 3
@Override
public int compareTo(TimestampedFilename other) {
  int res = prefix.compareTo(other.getPrefix());
  if (res == 0) {
    res = Longs.compare(timestamp, other.getTimestamp());
  }
  return res;
}
 
Example 4
Source Project: sasi   File: Token.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public int compareTo(CombinedValue<Long> o)
{
    return Longs.compare(token, ((Token) o).token);
}
 
Example 5
Source Project: Singularity   File: S3LogResource.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public int compare(SingularityS3LogMetadata o1, SingularityS3LogMetadata o2) {
  return Longs.compare(o2.getLastModified(), o1.getLastModified());
}
 
Example 6
/**
 * {@inheritDoc}
 */
@Override
public int compareTo(JobId jobId) {
    return Longs.compare(id, ((JobIdImpl) jobId).id);
}
 
Example 7
@Override
public int compareTo(UsageStats other) {
	return Longs.compare(timesSeen, other.timesSeen);
}
 
Example 8
Source Project: pulsar   File: EntryCacheImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public int compareTo(EntryCache other) {
    return Longs.compare(getSize(), other.getSize());
}
 
Example 9
@Override
public int compareTo(SingularityTaskShellCommandRequest o) {
  return Longs.compare(o.getTimestamp(), timestamp);
}
 
Example 10
Source Project: phoenix   File: PMetaDataImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public int compare(PTableRef tableRef1, PTableRef tableRef2) {
    return Longs.compare(tableRef1.lastAccessTime, tableRef2.lastAccessTime);
}
 
Example 11
Source Project: GreenBits   File: Coin.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public int compareTo(final Coin other) {
    return Longs.compare(this.value, other.value);
}
 
Example 12
Source Project: glowroot   File: HeapHistogramTool.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public int compare(ClassInfo left, ClassInfo right) {
    return Longs.compare(right.bytes, left.bytes);
}
 
Example 13
Source Project: java   File: DefaultDelayingQueue.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public int compareTo(Delayed o) {
  return Longs.compare(getDelay(TimeUnit.MILLISECONDS), o.getDelay(TimeUnit.MILLISECONDS));
}
 
Example 14
/**
 * Compare with the other weightedMultiWorkUnit based on weight.
 */
@Override
public int compareTo(WeightedMultiWorkUnit weightedMultiWorkUnit) {
  return Longs.compare(this.weight, weightedMultiWorkUnit.getWeight());
}
 
Example 15
public static int compare(JanusGraphElement e1, JanusGraphElement e2) {
    long e1id = (e1 instanceof AbstractElement) ? ((AbstractElement) e1).getCompareId() : e1.longId();
    long e2id = (e2 instanceof AbstractElement) ? ((AbstractElement) e2).getCompareId() : e2.longId();
    return Longs.compare(e1id, e2id);
}
 
Example 16
Source Project: imhotep   File: SimpleFlamdexWriter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public int compareTo(IntTermIteratorWrapper o) {
    final int cmp;
    return (cmp = Longs.compare(it.term(), o.it.term())) != 0 ? cmp : Ints.compare(index, o.index);
}
 
Example 17
Source Project: titan1withtp3.1   File: AbstractElement.java    License: Apache License 2.0 4 votes vote down vote up
public static int compare(TitanElement e1, TitanElement e2) {
    long e1id = (e1 instanceof AbstractElement)?((AbstractElement)e1).getCompareId():e1.longId();
    long e2id = (e2 instanceof AbstractElement)?((AbstractElement)e2).getCompareId():e2.longId();
    return Longs.compare(e1id,e2id);
}
 
Example 18
@Override
public int compare(GroupedMultiErrorInterval left, GroupedMultiErrorInterval right) {
    return Longs.compare(left.from(), right.from());
}
 
Example 19
Source Project: glowroot   File: JvmJsonService.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public int compare(ThreadDump.Thread left, ThreadDump.Thread right) {
    return Longs.compare(right.getId(), left.getId());
}
 
Example 20
Source Project: emodb   File: TimeUUIDs.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Compare the embedded timestamps of the given UUIDs. This is used when it is OK to return
 * an equality based on timestamps alone
 * @throws UnsupportedOperationException if either uuid is not a timestamp UUID
 */
public static int compareTimestamps(UUID uuid1, UUID uuid2) {
    return Longs.compare(uuid1.timestamp(), uuid2.timestamp());
}