Spring Framework ComparableComparator - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework ComparableComparator class.

This code example shows how to use the following methods:
		} 
 
	} 
 
 
	private static class TestComparator extends ComparableComparator<Integer> {
 
		private boolean called;
 
		@Override 
		public int compare(Integer o1, Integer o2) {
			assertThat(o1, instanceOf(Integer.class));
			assertThat(o2, instanceOf(Integer.class));
			this.called = true;
			return super.compare(o1, o2);
		}; 
 
		public void assertCalled() { 
			assertThat(this.called, is(true));
		} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 * in a special manner. In order to support comparison of numbers regardless of their type, this comparator transform 
 * the numbers to {@link BigDecimal} and then does the comparison. 
 * 
 * @author Uri Boness 
 */ 
public class NumberAwareComparableComparator extends ComparableComparator {
 
    /** 
     * Compares the two given objects. Expects both of them to be {@link Comparable} instances. 
     * 
     * @see ComparableComparator#compare(Object, Object) 
     */ 
    public int compare(Object o1, Object o2) {
        if (Number.class.isInstance(o1) && Number.class.isInstance(o2)) {
            return compareNumbers((Number) o1, (Number) o2);
        } 
        return super.compare(o1, o2);
 
    } 
 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 */ 
public class Minimum extends AbstractBinaryClosure { 
 
	private static final Minimum INSTANCE = new Minimum();
 
    private static final NullSafeComparator COMPARATOR = new NullSafeComparator(new ComparableComparator(), true);
 
	/** 
	 * Returns the shared instance--this is possible as the default functor for 
	 * this class is immutable and stateless. 
	 * 
	 * @return the shared instance 
	 */ 
	public static final BinaryClosure instance() { 
		return INSTANCE;
	} 
 
	/** 
	 * Return the minimum of two Comparable objects. 
	 * 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 * 
 * @author Keith Donald 
 */ 
public abstract class ComparisonBinaryPredicate extends AbstractBinaryConstraint { 
 
    private static final NullSafeComparator COMPARATOR = new NullSafeComparator(new ComparableComparator(), true);
 
	private Comparator comparator;
 
	/** 
	 * Creates a comparing binary predicate which operates on 
	 * <code>Comparable</code> objects. 
	 */ 
	protected ComparisonBinaryPredicate() { 
 
	} 
 
	/** 
	 * Creates a comparing binary predicate which compares using the provided 
	 * <code>Comparator</code>. 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        } catch (IllegalArgumentException iae) {
            // expected 
        } 
 
        try { 
            createCondition(null, new ComparableComparator());
            fail("An IllegalArgumentException must be thrown if the condition is initialized with a null bound"); 
        } catch (IllegalArgumentException iae) {
            // expected 
        } 
    } 
 
    public void testConstructor_WithNullComparator() throws Exception {
        try { 
            createCondition(new Person(5), null);
            fail("An IllegalArgumentException must be thrown if the condition is initialized with a null comparator"); 
        } catch (IllegalArgumentException iae) {
            // expected 
        } 
    } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        } catch (IllegalArgumentException iae) {
            // expected 
        } 
 
        try { 
            createBetweenCondition(null, new Integer(3), new ComparableComparator());
            fail("An IllegalArgumentException must be thrown if the condition is initialized with a null lower bound"); 
        } catch (IllegalArgumentException iae) {
            // expected 
        } 
    } 
 
    public void testConstructor_WithNullUpperBound() throws Exception {
        try { 
            createBetweenCondition(new Integer(3), null);
            fail("An IllegalArgumentException must be thrown if the condition is initialized with a null upper bound"); 
        } catch (IllegalArgumentException iae) {
            // expected 
        } 
 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 */ 
public class Maximum extends AbstractBinaryClosure { 
 
    private static final Maximum INSTANCE = new Maximum();
 
    private static final NullSafeComparator COMPARATOR = new NullSafeComparator(new ComparableComparator(), true);
 
	/** 
	 * Returns the shared instance--this is possible as the default functor for 
	 * this class is immutable and stateless. 
	 * 
	 * @return the shared instance 
	 */ 
	public static final BinaryClosure instance() { 
		return INSTANCE;
	} 
 
	/** 
	 * Return the maximum of the two Comparable objects. 
	 * 
4
CodeRank
Experience pair programming with AI  Get Codota for Java