Uploaded image for project: 'HAL'
  1. HAL
  2. HAL-1814

More iterations [for (Role role : roles)] can be avoid from isAdministrator() and isSuperuser() methods of User java class by using contains() of Set<> collection.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • None
    • 3.6.4.Final
    • None
    • None

      In [ org.jboss.hal.config.User.java ] , isAdministrator() and isSuperuser() methods contains the loop for checking  'ADMINISTRATOR' and 'SUPER_USER' . So, we can avoid the loop by using the collection contains() method in the code.

      -----------------------------

        for (Role role : roles) {

      if (ADMINISTRATOR.equals(role))

      { return true; }

      }

      --------------------------------------

      Replacing the old code with the given line of code:

      --------------------------------------

       if(roles.contains(ADMINISTRATOR)) { return true; } else { return false; }

      --------------

       

       

       

              rhn-support-saahamad Sarfaraz Ahamad
              rhn-support-saahamad Sarfaraz Ahamad
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: