@@ -0,0 +1,1239 @@
+package com.panjin.guava;%0A%0Aimport com.google.common.base.Function;%0Aimport com.google.common.collect.Ordering;%0Aimport com.google.common.primitives.Longs;%0Aimport com.panjin.pojo.CustomerBase;%0A%0Apublic class OrderingTest %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09CustomerBase customer1 = new CustomerBase();%0A%09%09customer1.setCustomerId(100L);%0A%09%09customer1.setCustomerName(%22customerName1%22);%0A%09%09CustomerBase customer2 = new CustomerBase();%0A%09%09customer2.setCustomerId(200L);%0A%09%09customer2.setCustomerName(%22customerName2%22);%0A%09%09%0A%09%09Ordering%3CCustomerBase%3E byCustomerIdOrdering = new Ordering%3CCustomerBase%3E() %7B%0A%09%09%09%0A%09%09%09@Override%0A%09%09%09public int compare(CustomerBase left, CustomerBase right) %7B%0A%09%09%09%09return Longs.compare(left.getCustomerId(), right.getCustomerId());%0A%09%09%09%7D%0A%09%09%7D;%0A%09%09%0A%09%09CustomerBase customer = byCustomerIdOrdering.min(customer1, customer1);%0A%09%09System.out.println(customer.equals(customer1));%0A%09%09%0A%09%09Ordering%3CCustomerBase%3E ordering = Ordering.natural().nullsFirst().onResultOf(new Function%3CCustomerBase, Long%3E() %7B%0A%09%09%09%0A%09%09%09@Override%0A%09%09%09public Long apply(CustomerBase input) %7B%0A%09%09%09%09return input.getCustomerId();%0A%09%09%09%7D%0A%09%09%7D);%0A%09%09%0A%09%09CustomerBase otherCustomer = ordering.max(customer1, customer2);%0A%09%09System.out.println(otherCustomer.equals(customer1));%0A%09%7D%0A%0A%7D%0A

add guava test code