List of usage examples for com.google.common.collect ComparisonChain compare
@Deprecated public final ComparisonChain compare(Boolean left, Boolean right)
From source file:edu.byu.nlp.util.DoubleArrays.java
public static int compareTo(double[] arr1, double[] arr2) { ComparisonChain chain = ComparisonChain.start().compare(arr1.length, arr2.length); for (int i = 0; i < arr1.length; i++) { chain = chain.compare(arr1[i], arr2[i]); }/*from w ww . j av a2 s . c om*/ return chain.result(); }
From source file:scoutdoc.main.check.dashboard.OutputElementComparator.java
@Override public int compare(OutputElement e1, OutputElement e2) { Check c1 = e1.getCheck();// w w w.jav a 2 s . c o m Check c2 = e2.getCheck(); ComparisonChain cc = ComparisonChain.start(); for (Column column : columns) { switch (column) { case PAGE: cc = cc.compare(c1.getPage(), c2.getPage()); break; case NAMESPACE: cc = cc.compare(c1.getPage().getType().name(), c2.getPage().getType().name()); break; case TYPE: cc = cc.compare(c1.getSeverity(), c2.getSeverity(), Ordering.explicit(Severity.error, Severity.warning, Severity.info)) .compare(c1.getType(), c2.getType()); break; default: throw new IllegalStateException("Unexpected column type"); } } return cc.result(); }
From source file:com.github.nethad.clustermeister.provisioning.ec2.AmazonGeneratedKeyPairCredentials.java
@Override public int compareTo(Credentials o) { ComparisonChain chain = ComparisonChain.start().compare(name, o.getName()).compare(user, o.getUser()); if (o instanceof AmazonGeneratedKeyPairCredentials) { chain.compare(privateKeyDigest.get(), o.as(AmazonGeneratedKeyPairCredentials.class).privateKeyDigest.get()); }//from w w w . ja v a 2s . c om return chain.result(); }
From source file:org.pircbotx.hooks.Event.java
/** * Compare events by {@link #getTimestamp()} and then {@link #getId()} to * order by when they are received. This is useful for sorting lists of * Channel objects.//ww w. ja v a 2 s .c o m * * @param other Other Event to compare to * @return the result of the comparison */ public int compareTo(Event other) { ComparisonChain comparison = ComparisonChain.start().compare(getTimestamp(), other.getTimestamp()) .compare(getId(), other.getId()); if (bot != null && other.getBot() != null) comparison.compare(bot.getBotId(), other.getBot().getBotId()); return comparison.result(); }
From source file:com.techcavern.pircbotz.hooks.Event.java
/** * Compare events by {@link #getTimestamp()} and then {@link #getId()} to * order by when they are received. This is useful for sorting lists of Channel objects. * @param other Other Event to compare to * @return the result of the comparison//from www . j a v a 2s .co m */ public int compareTo(Event<T> other) { ComparisonChain comparison = ComparisonChain.start().compare(getTimestamp(), other.getTimestamp()) .compare(getId(), other.getId()); if (bot != null && other.getBot() != null) comparison.compare(bot.getBotId(), other.getBot().getBotId()); return comparison.result(); }
From source file:com.facebook.buck.rules.BuildTargetSourcePath.java
@Override protected int compareReferences(BuildTargetSourcePath o) { if (o == this) { return 0; }/*from w w w .j a v a 2 s . co m*/ ComparisonChain comparison = ComparisonChain.start().compare(target, o.target) .compareTrueFirst(resolvedPath.isPresent(), o.resolvedPath.isPresent()); if (resolvedPath.isPresent() && o.resolvedPath.isPresent()) { comparison = comparison.compare(resolvedPath.get(), o.resolvedPath.get()); } return comparison.result(); }
From source file:com.facebook.buck.model.AbstractUnflavoredBuildTarget.java
@Override public int compareTo(AbstractUnflavoredBuildTarget o) { if (this == o) { return 0; }/* ww w . j a va2 s. c o m*/ ComparisonChain comparison = ComparisonChain.start().compareTrueFirst(getCell().isPresent(), o.getCell().isPresent()); if (getCell().isPresent() && o.getCell().isPresent()) { comparison = comparison.compare(getCell().get(), o.getCell().get()); } return comparison.compare(getBaseName(), o.getBaseName()).compare(getShortName(), o.getShortName()) .result(); }
From source file:org.spongepowered.common.data.manipulator.mutable.entity.SpongeBodyPartRotationalData.java
@Override public int compareTo(BodyPartRotationalData o) { int mapSizeComp = Integer.compare(this.rotations.size(), o.partRotation().size()); if (mapSizeComp != 0) { return mapSizeComp; }/*from w ww .j a v a2s. c o m*/ ComparisonChain comparison = ComparisonChain.start(); Map<BodyPart, Vector3d> parts = o.partRotation().get(); parts.forEach((part, vec) -> { comparison.compare(vec, this.rotations.get(part)); }); return comparison.result(); }
From source file:org.spongepowered.common.data.manipulator.immutable.entity.ImmutableSpongeBodyPartRotationalData.java
@Override public int compareTo(ImmutableBodyPartRotationalData o) { int mapSizeComp = Integer.compare(this.rotations.size(), o.partRotation().size()); if (mapSizeComp != 0) { return mapSizeComp; }//from w w w . j a va2 s. c o m ComparisonChain comparison = ComparisonChain.start(); Map<BodyPart, Vector3d> parts = o.partRotation().get(); parts.forEach((part, vec) -> { comparison.compare(vec, this.rotations.get(part)); }); return comparison.result(); }
From source file:org.obiba.mica.study.domain.DataCollectionEvent.java
@Override public int compareTo(@NotNull DataCollectionEvent dce) { ComparisonChain chain = ComparisonChain.start(); if (start != null && dce.start != null) { chain = chain.compare(start, dce.start); } else if (start != dce.start) { return start == null ? 1 : -1; }//from w ww. j a va2 s . co m if (end != null && dce.end != null) { chain = chain.compare(end, dce.end); } else if (end != dce.end) { return end == null ? 1 : -1; } return chain.compare(id, dce.id).result(); }