List of usage examples for com.google.common.collect ComparisonChain start
public static ComparisonChain start()
From source file:org.apache.isis.applib.util.ObjectContracts2.java
private static <T> int compare(final T p, final T q, final Iterable<String> propertyNamesIter) { if (p == null) { return -1; }// w w w . j a va2s . c o m if (q == null) { return +1; } if (p.getClass() != q.getClass()) { // just sort on the class type return Ordering.natural().onResultOf(new Function<Object, String>() { @Override public String apply(final Object o) { return o.getClass().getSimpleName(); } }).compare(p, q); } final Iterable<Clause> clauses = clausesFor(propertyNamesIter); ComparisonChain chain = ComparisonChain.start(); for (final Clause clause : clauses) { final Comparable<T> propertyValueOfP = (Comparable<T>) clause.getValueOf(p); final Comparable<T> propertyValueOfQ = (Comparable<T>) clause.getValueOf(q); chain = chain.compare(propertyValueOfP, propertyValueOfQ, clause.getDirection().getOrdering()); } return chain.result(); }
From source file:org.cinchapi.concourse.Tag.java
@Override public int compareTo(Tag other) { return ComparisonChain.start().compare(toString(), other.toString()).result(); }
From source file:io.seqware.webservice.generated.controller.ModelAccessionIDTuple.java
@Override public int compareTo(ModelAccessionIDTuple that) { return ComparisonChain.start().compare(this.id, that.id).compare(this.adminModelClass, that.adminModelClass) .compare(this.accession, that.accession).result(); }
From source file:org.opennms.features.topology.app.internal.jung.GridLayoutAlgorithm.java
/** * Updates the current layout by extracting the containers graph and then perform a (x,y) transformation * of all vertices./*from w w w .ja va2 s. co m*/ * * @param graphContainer The container of the current graph. Contains all relevant information to perform the transformation * of the {@link org.opennms.features.topology.api.Graph} by changing its {@link org.opennms.features.topology.api.Layout} */ @Override public void updateLayout(GraphContainer graphContainer) { final Graph graph = graphContainer.getGraph(); final Layout graphLayout = graph.getLayout(); // Sort the vertices final List<Vertex> sortedVertices = graph.getDisplayVertices().stream().sorted(new Comparator<Vertex>() { @Override public int compare(Vertex v1, Vertex v2) { return ComparisonChain.start().compare(getIndex(v1), getIndex(v2)) .compare(v1.getLabel(), v2.getLabel()).compare(v1.getId(), v2.getId()).result(); } }).collect(Collectors.toList()); // Find the smallest rectangle (grid) that will fit all the vertices // while attempting to preserve the aspect ration of the view port final int numberOfVertices = sortedVertices.size(); final BoundingBox layoutBounds = graphLayout.getBounds(); final BoundingBox grid = calculateGrid(numberOfVertices, layoutBounds.getWidth(), layoutBounds.getHeight()); // Layout the (sorted) vertices in the grid int k = 0; for (int y = 0; y < grid.getHeight(); y++) { for (int x = 0; x < grid.getWidth(); x++) { if (k >= numberOfVertices) { break; } graphLayout.setLocation(sortedVertices.get(k++), new Point(x * ELBOW_ROOM * 2, y * ELBOW_ROOM * 2)); } } }
From source file:se.kth.id2203.networking.NetAddress.java
@Override public int compareTo(NetAddress that) { return ComparisonChain.start() .compare(this.isa.getAddress().getAddress(), that.isa.getAddress().getAddress(), UnsignedBytes.lexicographicalComparator()) .compare(this.isa.getPort(), that.isa.getPort()).result(); }
From source file:org.spongepowered.common.data.manipulator.mutable.tileentity.SpongeNoteData.java
@Override public int compareTo(NoteData o) { return ComparisonChain.start().compare(note().get().getId(), o.note().get().getId()).result(); }
From source file:com.facebook.buck.core.model.AbstractUnconfiguredBuildTarget.java
@Override public int compareTo(UnconfiguredBuildTarget o) { if (this == o) { return 0; }/* w w w. ja v a 2 s . c om*/ return ComparisonChain.start().compare(getUnflavoredBuildTarget(), o.getUnflavoredBuildTarget()) .compare(getFlavors(), o.getFlavors(), LEXICOGRAPHICAL_ORDERING).result(); }
From source file:org.spongepowered.api.data.manipulator.immutable.common.AbstractImmutableBooleanData.java
@Override public int compareTo(I o) { return ComparisonChain.start().compare(o.get(this.usedKey).get(), this.getValue()).result(); }
From source file:org.dllearner.core.EvaluatedHypothesis.java
@Override public int compareTo(@NotNull EvaluatedHypothesis<T, S> o) { return ComparisonChain.start().compare(score.getAccuracy(), o.score.getAccuracy()) .compare(hypothesis, o.getDescription()).result(); }
From source file:org.spongepowered.common.data.manipulator.mutable.SpongeOwnableData.java
@Override public int compareTo(OwnableData o) { return ComparisonChain.start().compare(o.profile().get().getUniqueId(), this.profile.getUniqueId()) .compare(o.profile().get().getName(), this.profile.getName()).result(); }