Package org.springframework.beans.support

Examples of org.springframework.beans.support.PropertyComparator


  }

  public void testPropertyComparatorNulls() {
    Dog dog = new Dog();
    Dog dog2 = new Dog();
    PropertyComparator c = new PropertyComparator("nickName", false, true);
    assertTrue(c.compare(dog, dog2) == 0);
  }
View Full Code Here


    fail("illegal state should've been thrown on empty list");
  }

  public void testCompoundComparator() {
    CompoundComparator c = new CompoundComparator();
    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);

    dog2.setLastName("konikk dog");
    assertTrue(c.compare(dog2, dog1) > 0);
  }
View Full Code Here

    assertTrue(c.compare(dog2, dog1) > 0);
  }

  public void testCompoundComparatorInvert() {
    CompoundComparator c = new CompoundComparator();
    c.addComparator(new PropertyComparator("lastName", false, true));
    c.addComparator(new PropertyComparator("firstName", false, true));
    Dog dog1 = new Dog();
    dog1.setFirstName("macy");
    dog1.setLastName("grayspots");

    Dog dog2 = new Dog();
View Full Code Here

      EventList<T> rawList = GlazedLists.eventList( data );
      int initialSortColumn = getInitialSortColumn();
      if ( initialSortColumn >= 0 ) {
        PropertyPath sortProperty = getColumnDefinition( initialSortColumn ).getPropertyPath();
        //noinspection unchecked
        baseEventList = new SortedList<T>( rawList, new PropertyComparator( sortProperty.getProperty(), false, true ) );
      } else {
        baseEventList = new SortedList<T>( rawList );
      }
    }
    //noinspection ReturnOfCollectionOrArrayField
View Full Code Here

    }

    public static void sort(List list, String field, Boolean desc) {
        if (list != null && field != null) {
            boolean asc = (desc == null || !desc);
            Collections.sort(list, new PropertyComparator(field, true, asc));
        }
    }
View Full Code Here

TOP

Related Classes of org.springframework.beans.support.PropertyComparator

Copyright © 2018 www.massapicom. 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.