Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: current
    • Fix Version/s: 1.8.0
    • Component/s: core
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      330

      Description

      Setting up static collections can be simplified with varargs support. For
      example, add a BasicEventList constructor w/ a signature of BasicEventList(E ...
      elements). Or, add a helper method in GlazedLists.java: EventList<E>
      eventList(E ... elements).

      Also add a varargs constructor to CompositeMatcherEditor. The current
      constructor takes an EventList which is a bit of pain to setup. This is the
      primary motivation for me to add this issue.

        Activity

        Hide
        jessewilson added a comment -

        Brilliant idea. I'm thinking the following new methods on our factory classes:
        public List<T> GlazedLists.eventList(T... contents)
        public MatcherEditor<T> Matchers.matchAll(MatcherEditor<T>... contents);
        public MatcherEditor<T> Matchers.matchAny(MatcherEditor<T>... contents);

        The only snag I fear is that the eventList() method is already being used with
        the following signature, which may collide with varargs:
        public EventList<T> GlazedLists.eventList(Collection contents)
        If that's the case we'll have to change this constructor name to newEventList().

        What do you think?

        Show
        jessewilson added a comment - Brilliant idea. I'm thinking the following new methods on our factory classes: public List<T> GlazedLists.eventList(T... contents) public MatcherEditor<T> Matchers.matchAll(MatcherEditor<T>... contents); public MatcherEditor<T> Matchers.matchAny(MatcherEditor<T>... contents); The only snag I fear is that the eventList() method is already being used with the following signature, which may collide with varargs: public EventList<T> GlazedLists.eventList(Collection contents) If that's the case we'll have to change this constructor name to newEventList(). What do you think?
        Hide
        jplemieux added a comment -

        Done.

        Hacking Declawer proved to be easy in this case. varargs truly are syntactic
        sugar, and this is evident in the Abstract Syntax Tree that the JavaCompiler
        builds. Specifically, args that actually are varargs are IDENTICAL to Object[]
        args except for a flag that indicates they use the special syntax for varargs.
        Thus, a new TreeScanner need only remove the flag for VARARGS and when the AST
        is written back out, we get an Object[] in place of the vararg for our JDK 1.4
        build.

        Show
        jplemieux added a comment - Done. Hacking Declawer proved to be easy in this case. varargs truly are syntactic sugar, and this is evident in the Abstract Syntax Tree that the JavaCompiler builds. Specifically, args that actually are varargs are IDENTICAL to Object[] args except for a flag that indicates they use the special syntax for varargs. Thus, a new TreeScanner need only remove the flag for VARARGS and when the AST is written back out, we get an Object[] in place of the vararg for our JDK 1.4 build.
        Hide
        brands added a comment -

        changing milestone

        Show
        brands added a comment - changing milestone
        Hide
        brands added a comment -

        In summary:

        • added GlazedLists.eventListOf(E... contents);
        • added GlazedLists.chainComparators(Comparator<T>... comparators);
        • changed GlazedLists.filterator(..) and GlazedLists.textFilterator(..) methods
        • added Matchers.or(Matcher<? super E>... matchers);
        • added Matchers.and(Matcher<? super E>... matchers);
        Show
        brands added a comment - In summary: added GlazedLists.eventListOf(E... contents); added GlazedLists.chainComparators(Comparator<T>... comparators); changed GlazedLists.filterator(..) and GlazedLists.textFilterator(..) methods added Matchers.or(Matcher<? super E>... matchers); added Matchers.and(Matcher<? super E>... matchers);

          People

          • Assignee:
            jessewilson
            Reporter:
            neilweber
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: