glazedlists
  1. glazedlists
  2. GLAZEDLISTS-485

Additional constructor for CompositeList

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 0.9.1
    • Fix Version/s: milestone 1
    • Component/s: core
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      485

      Description

      I often find that I need a composite list that merges the results of 2 or 3
      fixed lists (i.e. those lists will never change). The following constructor
      helps with two things:

      1. It simplifies the code
      2. It provides a workaround for issue 484 for a number of relatively common
      cases (https://glazedlists.dev.java.net/issues/show_bug.cgi?id=484) (I'd still
      prefer to get 484 fixed, of course)

      public CompositeList(EventList<E>... sources) {
      super(eventListFromArray(sources, sources[0].getPublisher(),
      sources[0].getReadWriteLock()), (Model)GlazedLists.listCollectionListModel());

      ListEventPublisher pub = sources[0].getPublisher();
      ReadWriteLock lok = sources[0].getReadWriteLock();
      for (EventList<E> eventList : sources)

      { if (eventList.getPublisher() != pub) throw new IllegalArgumentException("Member list must share publisher with CompositeList"); if (eventList.getReadWriteLock() != lok) throw new IllegalArgumentException("Member list must share lock with CompositeList"); }

      }

      private static <E> EventList<E> eventListFromArray(E[] source,
      ListEventPublisher publisher, ReadWriteLock lock)

      { EventList<E> l = new BasicEventList<E>(publisher, lock); l.addAll(Arrays.asList(source)); return l; }

        Activity

        Hide
        trumpetinc added a comment -

        PS - the static method below could be replaced to a call to the GlazedLists
        method requested here: https://glazedlists.dev.java.net/issues/show_bug.cgi?id=483

        Show
        trumpetinc added a comment - PS - the static method below could be replaced to a call to the GlazedLists method requested here: https://glazedlists.dev.java.net/issues/show_bug.cgi?id=483

          People

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

            Dates

            • Created:
              Updated: