Package com.google.common.collect

Examples of com.google.common.collect.ComparisonChain.compare()


    public static <T> int compare(T p, T q, String propertyNames) {
        ComparisonChain chain = ComparisonChain.start();
        for (final Clause clause : iterable(propertyNames)) {
            final Comparable<T> propertyValue = (Comparable<T>) clause.getValueOf(p);
            final Comparable<T> propertyValue2 = (Comparable<T>) clause.getValueOf(q);
            chain = chain.compare(propertyValue, propertyValue2, clause.getDirection().getOrdering());
        }
        return chain.result();
    }

    public static <T> Comparator<T> compareBy(final String propertyNames){
View Full Code Here


    public static <T> int compare(T p, T q, String propertyNames) {
        ComparisonChain chain = ComparisonChain.start();
        for (final Clause clause : iterable(propertyNames)) {
            final Comparable<T> propertyValue = (Comparable<T>) clause.getValueOf(p);
            final Comparable<T> propertyValue2 = (Comparable<T>) clause.getValueOf(q);
            chain = chain.compare(propertyValue, propertyValue2, clause.getDirection().getOrdering());
        }
        return chain.result();
    }

    public static <T> Comparator<T> compareBy(final String propertyNames){
View Full Code Here

    public static <T> int compare(T p, T q, String propertyNames) {
        ComparisonChain chain = ComparisonChain.start();
        for (final Clause clause : iterable(propertyNames)) {
            final Comparable<T> propertyValue = (Comparable<T>) clause.getValueOf(p);
            final Comparable<T> propertyValue2 = (Comparable<T>) clause.getValueOf(q);
            chain = chain.compare(propertyValue, propertyValue2, clause.getDirection().getOrdering());
        }
        return chain.result();
    }

View Full Code Here

                    .compare(h1.getRam(), h2.getRam())
                    .compare(getSpace(h1), getSpace(h2))
                    .compare(getBootableDeviceType(h1), getBootableDeviceType(h2));
            if (!volumes1.isEmpty() && !volumes2.isEmpty() && volumes1.size() == volumes2.size()) {
               for (int i = 0; i < volumes1.size(); i++) {
                  comparisonChain.compare(volumes1.get(i).getType(), volumes2.get(i).getType());
               }
            }
            return comparisonChain.result();
         }
      });
View Full Code Here

        // It should never get to this point in the code. Because we are using an Interner, two objects that are equal
        // are the same object, so the first check will return 0. If the objects are not equal, at least one of the
        // three values we check before the list will be unequal, so it should never have to compare the contents of the
        // lists (thankfully).
        for (int i = 0; i < keys.size(); i++) {
            result = cmpChain.compare(keys.get(i), that.keys.get(i)).result();
            if (result != 0) return result;
        }

        return result;
    }
View Full Code Here

                    .compare(h1.getRam(), h2.getRam())
                    .compare(getSpace(h1), getSpace(h2))
                    .compare(getBootableDeviceType(h1), getBootableDeviceType(h2));
            if (!volumes1.isEmpty() && !volumes2.isEmpty() && volumes1.size() == volumes2.size()) {
               for (int i = 0; i < volumes1.size(); i++) {
                  comparisonChain.compare(volumes1.get(i).getType(), volumes2.get(i).getType());
               }
            }
            return comparisonChain.result();
         }
      });
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.