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

The following examples show how to use com.google.common.primitives.Longs#compare() .
Example 1
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
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
Project: phoenix-tephra   File: HDFSTransactionStateStorage.java    License: Apache License 2.0 5 votes vote down vote up
@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
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
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
Project: scheduling   File: JobIdImpl.java    License: GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public int compareTo(JobId jobId) {
    return Longs.compare(id, ((JobIdImpl) jobId).id);
}
 
Example 7
Project: naturalize   File: VariableUsageStatistics.java    License: BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public int compareTo(UsageStats other) {
	return Longs.compare(timesSeen, other.timesSeen);
}
 
Example 8
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
Project: Singularity   File: SingularityTaskShellCommandRequest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public int compareTo(SingularityTaskShellCommandRequest o) {
  return Longs.compare(o.getTimestamp(), timestamp);
}
 
Example 10
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
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
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
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
Project: incubator-gobblin   File: MultiWorkUnitWeightedQueue.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Compare with the other weightedMultiWorkUnit based on weight.
 */
@Override
public int compareTo(WeightedMultiWorkUnit weightedMultiWorkUnit) {
  return Longs.compare(this.weight, weightedMultiWorkUnit.getWeight());
}
 
Example 15
Project: grakn   File: AbstractElement.java    License: GNU Affero General Public License v3.0 4 votes vote down vote up
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
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
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
Project: glowroot   File: MultiErrorIntervalMerger.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public int compare(GroupedMultiErrorInterval left, GroupedMultiErrorInterval right) {
    return Longs.compare(left.from(), right.from());
}
 
Example 19
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
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());
}