Examples of AtLeastMatcherEditor


Examples of ca.odell.glazedlists.impl.testing.AtLeastMatcherEditor

     * <p>FilterList<Number> can accept a MatcherEditor<Number> or MatcherEditor<Object>, but not
     * a MatcherEditor<Integer>.
     */
    public void testGenericsCompile() {
        final Matcher<Number> numberMatcher = GlazedListsTests.matchAtLeast(0);
        final MatcherEditor<Number> numberMatcherEditor = new AtLeastMatcherEditor();

        // constructor should accept Matcher<Object>
        new FilterList<Number>(new BasicEventList<Number>(), Matchers.falseMatcher());
        // constructor should accept Matcher<Number>
        new FilterList<Number>(new BasicEventList<Number>(), numberMatcher);
View Full Code Here

Examples of ca.odell.glazedlists.impl.testing.AtLeastMatcherEditor

        EventList<Integer> original = new BasicEventList<Integer>();
        List<Integer> values = GlazedListsTests.intArrayToIntegerCollection(new int [] { 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 11, 11, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 10, 11, 11, 11, 11, 11, 11, 11, 10, 11, 11, 11, 11, 11, 10, 11, 11, 11, 11, 11, 11, 11, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 1 });
        original.addAll(values);
       
        // prepare a filter to filter our list
        AtLeastMatcherEditor editor = new AtLeastMatcherEditor();
        FilterList<Integer> myFilterList = new FilterList<Integer>(original, editor);
        ListConsistencyListener<Integer> listConsistencyListener = ListConsistencyListener.install(myFilterList);
        listConsistencyListener.setPreviousElementTracked(true);


        // relax the list
        editor.setMinimum(11);
        assertEquals(myFilterList, Matchers.select(original, editor.getMatcher()));
        editor.setMinimum(10);
        assertEquals(myFilterList, Matchers.select(original, editor.getMatcher()));
        editor.setMinimum(0);
        assertEquals(myFilterList, Matchers.select(original, editor.getMatcher()));
        editor.setMinimum(10);
        assertEquals(myFilterList, Matchers.select(original, editor.getMatcher()));
        editor.setMinimum(11);
        assertEquals(myFilterList, Matchers.select(original, editor.getMatcher()));
        editor.setMinimum(0);
        assertEquals(myFilterList, Matchers.select(original, editor.getMatcher()));
       
        // now try constrain
        values = GlazedListsTests.intArrayToIntegerCollection(new int[] { 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 });
        original.clear();
        original.addAll(values);
       
        // constrain the list
        editor.setMinimum(10);
        assertEquals(myFilterList, Matchers.select(original, editor.getMatcher()));
        editor.setMinimum(11);
        assertEquals(myFilterList, Matchers.select(original, editor.getMatcher()));
        editor.setMinimum(12);
        assertEquals(myFilterList, Matchers.select(original, editor.getMatcher()));
        editor.setMinimum(10);
        assertEquals(myFilterList, Matchers.select(original, editor.getMatcher()));

        // now try more changes
        values = GlazedListsTests.intArrayToIntegerCollection(new int[] { 8, 6, 7, 5, 3, 0, 9 });
        original.clear();
        original.addAll(values);

        // constrain the list
        editor.setMinimum(5);
        assertEquals(myFilterList, Matchers.select(original, editor.getMatcher()));
        editor.setMinimum(10);
        assertEquals(myFilterList, Matchers.select(original, editor.getMatcher()));
        editor.setMinimum(1);
        assertEquals(myFilterList, Matchers.select(original, editor.getMatcher()));
        editor.setMinimum(0);
        assertEquals(myFilterList, Matchers.select(original, editor.getMatcher()));
        editor.setMinimum(1);
        assertEquals(myFilterList, Matchers.select(original, editor.getMatcher()));

    }
View Full Code Here

Examples of ca.odell.glazedlists.impl.testing.AtLeastMatcherEditor

        }

        // create sorted and filtered derivatives
        Comparator<Number> comparator = (Comparator)GlazedLists.comparableComparator();
        SortedList<Number> sorted = new SortedList<Number>(root, comparator);
        AtLeastMatcherEditor matcherEditor = new AtLeastMatcherEditor(50);
        FilterList<Number> filtered = new FilterList<Number>(root, matcherEditor);

        // repeatedly make updates and verify the derivates keep up
        for(int i = 0; i < 30; i++) {
            // add 100 elements
            for(int j = 0; j < 100; j++) {
                Integer value = new Integer(random.nextInt(100));
                root.add(value);
                control.add(value);
            }

            // verify the base list is correct
            assertEquals(root, control);

            // verify that the sorted list is correct
            List<Number> sortedControl = new ArrayList<Number>();
            sortedControl.addAll(control);
            Collections.sort(sortedControl, sorted.getComparator());
            assertEquals(sortedControl, sorted);

            // verify that the filtered list is correct
            List<Number> filteredControl = new ArrayList<Number>();
            for(int j = 0; j < control.size(); j++) {
                if(matcherEditor.getMatcher().matches(control.get(j))) {
                    filteredControl.add(control.get(j));
                }
            }
            assertEquals(filteredControl, filtered);

            // adjust the sorter
            if(comparator instanceof ReverseComparator) {
                comparator = (Comparator)GlazedLists.comparableComparator();
            } else {
                comparator = GlazedLists.reverseComparator(comparator);
            }
            sorted.setComparator(comparator);

            // adjust the filter
            matcherEditor.setMinimum(random.nextInt(100));
        }
    }
View Full Code Here

Examples of ca.odell.glazedlists.impl.testing.AtLeastMatcherEditor

        // decide our update strategy
        String updateStrategy = getParam("GlazedLists.ThreadProxyUpdateStrategy");

        // prepare a matcher, we change this every iteration
        matcherEditor = new AtLeastMatcherEditor();

        // create a short pipeline, ending in a thread proxied list
        EventList<Integer> base = new BasicEventList<Integer>();
        EventList<Integer> filtered = new FilterList<Integer>(base, matcherEditor);
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.