Package org.andromda.utils.beans

Examples of org.andromda.utils.beans.SortCriteria$Ordering


        final List persons = Arrays.asList(BeanSorterTest.persons);

        // - try simple property sorting
        List sorted = BeanSorter.sort(
            persons,
            new SortCriteria[] {new SortCriteria(
                    "firstName",
                    Ordering.ASCENDING)});
        Iterator iterator = sorted.iterator();
        Person billy =  (Person)iterator.next();
        assertEquals(billy.getFirstName(), "Billy");
        Person chad = (Person)iterator.next();
        assertEquals(chad.getFirstName(), "Chad");
        Person john = (Person)iterator.next();
        assertEquals(john.getFirstName(), "John");

        sorted = BeanSorter.sort(
            persons,
            new SortCriteria[] {new SortCriteria(
                    "firstName",
                    Ordering.DESCENDING)});
        iterator = sorted.iterator();
        john =  (Person)iterator.next();
        assertEquals(john.getFirstName(), "John");
        chad = (Person)iterator.next();
        assertEquals(chad.getFirstName(), "Chad");
        billy = (Person)iterator.next();
        assertEquals(billy.getFirstName(), "Billy");
       
        // - try nested property sorting
        sorted = BeanSorter.sort(
            persons,
            new SortCriteria[] {new SortCriteria(
                    "address.streetNumber",
                    Ordering.ASCENDING)});     
        iterator = sorted.iterator();
        john =  (Person)iterator.next();
        assertEquals(john.getFirstName(), "John");
        chad = (Person)iterator.next();
        assertEquals(chad.getFirstName(), "Chad");
        billy = (Person)iterator.next();
        assertEquals(billy.getFirstName(), "Billy");
       
        sorted = BeanSorter.sort(
            persons,
            new SortCriteria[] {new SortCriteria(
                    "address.streetNumber",
                    Ordering.DESCENDING)});     
        iterator = sorted.iterator();
        billy =  (Person)iterator.next();
        assertEquals(billy.getFirstName(), "Billy");
View Full Code Here

TOP

Related Classes of org.andromda.utils.beans.SortCriteria$Ordering

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.