Lucene - Core
  1. Lucene - Core
  2. LUCENE-1989

CharArraySet cannot be made generic, because it violates the Set<char[]> interface

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.9
    • Fix Version/s: 3.0
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      I tried to make CharArraySet using generics (extends AbstractSet<char[]>) but this is not possible, as it e.g. returns sometimes String instances in the Iterator instead of []. Also its addAll method accepts both String and char[]. I think this class is a complete mis-design and violates almost everything (sorry).

      What to do? Make it Set<?> or just place a big @SuppressWarnings("unchecked"> in front of it?

      Because of this problem also a lot of Set declarations inside StopAnalyzer cannot be made generic as you never know whats inside.

      1. LUCENE-1989.patch
        2 kB
        Uwe Schindler
      2. LUCENE-1989.patch
        3 kB
        Uwe Schindler

        Issue Links

          Activity

          Hide
          Uwe Schindler added a comment - - edited

          This is the only possibility to make it somehow genericfied. As all Object subclasses (so everything) contains a toString() method it is no longer a problem to add any object that has a valid String representation to this set.

          It is only strange that the iterator returns Strings and not char[] - why is this so? To fix this, there is also an accessor to get an Iterator<String> correctly casted.

          Show
          Uwe Schindler added a comment - - edited This is the only possibility to make it somehow genericfied. As all Object subclasses (so everything) contains a toString() method it is no longer a problem to add any object that has a valid String representation to this set. It is only strange that the iterator returns Strings and not char[] - why is this so? To fix this, there is also an accessor to get an Iterator<String> correctly casted.
          Hide
          Uwe Schindler added a comment -

          Add some java docs. Will commit now.

          Show
          Uwe Schindler added a comment - Add some java docs. Will commit now.
          Hide
          Uwe Schindler added a comment -

          Committed revision: 826395

          Show
          Uwe Schindler added a comment - Committed revision: 826395

            People

            • Assignee:
              Uwe Schindler
              Reporter:
              Uwe Schindler
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development