Package java.util

Examples of java.util.Comparator.compare()


      {
  harness.check(true);
      }
    try
      {
  c.compare("", null);
  harness.fail("expected NullPointerException");
      }
    catch (NullPointerException e)
      {
  harness.check(true);
View Full Code Here


      {
  harness.check(true);
      }
    try
      {
  c.compare(this, "");
  harness.fail("expected ClassCastException");
      }
    catch (ClassCastException e)
      {
  harness.check(true);
View Full Code Here

      {
  harness.check(true);
      }
    try
      {
  c.compare("", this);
  harness.fail("expected ClassCastException");
      }
    catch (ClassCastException e)
      {
  harness.check(true);
View Full Code Here

     */
    public static int compare(Object o1, Object o2, Class<?> clazz, ComparatorContext context) {
        Comparator comparator = getComparator(clazz, context);
        if (comparator != null) {
            try {
                return comparator.compare(o1, o2);
            }
            catch (Exception e) {
                // ignore and let the code below handles it.
            }
        }
View Full Code Here

    Comparator comp = new SearchHitByDateComparator();

    SearchHit h1 = new SearchHit(null, "", "", "", "", new Date(321), 1.0F);
    SearchHit h2 = new SearchHit(null, "", "", "", "", new Date(123), 1.0F);

    assertTrue(comp.compare(h1, h1) == 0);
    assertTrue(comp.compare(h1, h2) != 0);
    assertTrue(comp.compare(h1, h2) < 0);
    assertTrue(comp.compare(h2, h1) > 0);
  }
View Full Code Here

    SearchHit h1 = new SearchHit(null, "", "", "", "", new Date(321), 1.0F);
    SearchHit h2 = new SearchHit(null, "", "", "", "", new Date(123), 1.0F);

    assertTrue(comp.compare(h1, h1) == 0);
    assertTrue(comp.compare(h1, h2) != 0);
    assertTrue(comp.compare(h1, h2) < 0);
    assertTrue(comp.compare(h2, h1) > 0);
  }

}
View Full Code Here

    SearchHit h1 = new SearchHit(null, "", "", "", "", new Date(321), 1.0F);
    SearchHit h2 = new SearchHit(null, "", "", "", "", new Date(123), 1.0F);

    assertTrue(comp.compare(h1, h1) == 0);
    assertTrue(comp.compare(h1, h2) != 0);
    assertTrue(comp.compare(h1, h2) < 0);
    assertTrue(comp.compare(h2, h1) > 0);
  }

}
View Full Code Here

    SearchHit h2 = new SearchHit(null, "", "", "", "", new Date(123), 1.0F);

    assertTrue(comp.compare(h1, h1) == 0);
    assertTrue(comp.compare(h1, h2) != 0);
    assertTrue(comp.compare(h1, h2) < 0);
    assertTrue(comp.compare(h2, h1) > 0);
  }

}
View Full Code Here

    Comparator comp = new SearchHitByScoreComparator();

    SearchHit h1 = new SearchHit(null, "", "", "", "", new Date(123), 0.5F);
    SearchHit h2 = new SearchHit(null, "", "", "", "", new Date(321), 0.3F);

    assertTrue(comp.compare(h1, h1) == 0);
    assertTrue(comp.compare(h1, h2) != 0);
    assertTrue(comp.compare(h1, h2) < 0);
    assertTrue(comp.compare(h2, h1) > 0);
  }
View Full Code Here

    SearchHit h1 = new SearchHit(null, "", "", "", "", new Date(123), 0.5F);
    SearchHit h2 = new SearchHit(null, "", "", "", "", new Date(321), 0.3F);

    assertTrue(comp.compare(h1, h1) == 0);
    assertTrue(comp.compare(h1, h2) != 0);
    assertTrue(comp.compare(h1, h2) < 0);
    assertTrue(comp.compare(h2, h1) > 0);
  }

}
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.