Spring Framework CompoundComparator - 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 CompoundComparator class.

This code example shows how to use the following methods:
	} 
 
	@SuppressWarnings("unchecked") 
	@Test
	public void testCompoundComparator() { 
		CompoundComparator<Dog> c = new CompoundComparator<Dog>();
		c.addComparator(new PropertyComparator("lastName", false, true));
 
		Dog dog1 = new Dog();
		dog1.setFirstName("macy");
		dog1.setLastName("grayspots");
 
		Dog dog2 = new Dog();
		dog2.setFirstName("biscuit");
		dog2.setLastName("grayspots");
 
		assertTrue(c.compare(dog1, dog2) == 0);
 
		c.addComparator(new PropertyComparator("firstName", false, true));
		assertTrue(c.compare(dog1, dog2) > 0);
5
CodeRank
Experience pair programming with AI  Get Codota for Java