Uploaded image for project: 'Grouper'
  1. Grouper
  2. GRP-1969

Change API methods returning generic Sets to include payload type

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Minor
    • None
    • 2.4.0
    • API
    • None

    Description

      A few methods define a generic Set as the return, without defining what type of object it's returning. For example

      public Set edu.internet2.middleware.grouper.Stem#getChildGroups()
       
      //vs.
       
      public Set<Group> edu.internet2.middleware.grouper.Stem#getChildGroups(Scope scope)
      

      This means that callers can't write something like ```for (Group g: stem.getChildGroups())``` because the IDE complains "incompatible types: Object cannot be converted to Group".

      Of course you can change it to Object and then cast it to Group inside the loop, but it's messy. Or, you can call stem.getChildGroups(Stem.Scope.ONE) which does set the payload to Group (and which getChildGroups() calls but then strips out the payload type).

      Best would a simple change to define the payload for methods returning collections. I addition to the above, it may also uncover hidden bugs where the wrong class was being assumed in a method call.

      Attachments

        Activity

          People

            chris.hyzer@at.internet2.edu Chris Hyzer (upenn.edu)
            chad.redman@at.internet2.edu Chad Redman (unc.edu)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: