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

Change API methods returning generic Sets to include payload type

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.4.0
    • Fix Version/s: None
    • Component/s: API
    • Labels:
      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

            • Assignee:
              mchyzer Chris Hyzer
              Reporter:
              cer28 Chad Redman
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: