This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 40e0021fa9e4560a079181012e0c0059eacf9667
Author: juanpablo <[email protected]>
AuthorDate: Fri Mar 27 18:14:22 2020 +0100

    add format & fixes suggested by IntelliJ
---
 .../org/apache/wiki/auth/acl/AclEntryImpl.java     | 116 +++++++++------------
 .../java/org/apache/wiki/auth/acl/AclImpl.java     |   4 +-
 2 files changed, 52 insertions(+), 68 deletions(-)

diff --git 
a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/AclEntryImpl.java 
b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/AclEntryImpl.java
index 46d8a35..d7a75a2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/AclEntryImpl.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/AclEntryImpl.java
@@ -18,48 +18,42 @@
  */
 package org.apache.wiki.auth.acl;
 
+import org.apache.wiki.auth.permissions.PagePermission;
+
 import java.io.Serializable;
 import java.security.Permission;
 import java.security.Principal;
 import java.util.Enumeration;
 import java.util.Vector;
 
-import org.apache.wiki.auth.permissions.PagePermission;
 
 /**
  * Implementation of a JSPWiki AclEntry.
  *
  * @since 2.3
  */
-public class AclEntryImpl implements AclEntry, Serializable
-{
+public class AclEntryImpl implements AclEntry, Serializable {
+
     private static final long serialVersionUID = 1L;
-    private Vector<Permission>    m_permissions = new Vector<Permission>();
+    private Vector< Permission > m_permissions = new Vector<>();
     private Principal m_principal;
 
     /**
      * Constructs a new AclEntryImpl instance.
      */
-    public AclEntryImpl()
-    {
+    public AclEntryImpl() {
     }
 
     /**
-     * Adds the specified permission to this ACL entry. The permission
-     * <em>must</em> be of type
-     * {@link org.apache.wiki.auth.permissions.PagePermission}. Note: An entry
-     * can have multiple permissions.
-     * @param permission the permission to be associated with the principal in
-     *            this entry
-     * @return <code>true</code> if the permission was added, 
-     *         <code>false</code> if the permission was
-     *         already part of this entry's permission set, and 
<code>false</code> if
-     *         the permission is not of type PagePermission
+     * Adds the specified permission to this ACL entry. The permission 
<em>must</em> be of type
+     * {@link org.apache.wiki.auth.permissions.PagePermission}. Note: An entry 
can have multiple permissions.
+     *
+     * @param permission the permission to be associated with the principal in 
this entry
+     * @return <code>true</code> if the permission was added, 
<code>false</code> if the permission was
+     * already part of this entry's permission set, and <code>false</code> if 
the permission is not of type PagePermission
      */
-    public synchronized boolean addPermission( Permission permission )
-    {
-        if ( permission instanceof PagePermission && findPermission( 
permission ) == null )
-        {
+    public synchronized boolean addPermission( final Permission permission ) {
+        if( permission instanceof PagePermission && findPermission( permission 
) == null ) {
             m_permissions.add( permission );
             return true;
         }
@@ -68,48 +62,43 @@ public class AclEntryImpl implements AclEntry, Serializable
     }
 
     /**
-     * Checks if the specified permission is part of the permission set in this
-     * entry.
+     * Checks if the specified permission is part of the permission set in 
this entry.
+     *
      * @param permission the permission to be checked for.
-     * @return true if the permission is part of the permission set in this 
entry,
-     *         false otherwise.
+     * @return true if the permission is part of the permission set in this 
entry, false otherwise.
      */
-    public boolean checkPermission( Permission permission )
-    {
+    public boolean checkPermission( final Permission permission ) {
         return findPermission( permission ) != null;
     }
 
     /**
-     * Returns the principal for which permissions are granted by this
-     * ACL entry. Returns null if there is no principal set for this entry yet.
+     * Returns the principal for which permissions are granted by this ACL 
entry. Returns null if there is no principal set for this
+     * entry yet.
+     *
      * @return the principal associated with this entry.
      */
-    public synchronized Principal getPrincipal()
-    {
+    public synchronized Principal getPrincipal() {
         return m_principal;
     }
 
     /**
      * Returns an enumeration of the permissions in this ACL entry.
+     *
      * @return an enumeration of the permissions
      */
-    public Enumeration< Permission > permissions()
-    {
+    public Enumeration< Permission > permissions() {
         return m_permissions.elements();
     }
 
     /**
      * Removes the specified permission from this ACL entry.
+     *
      * @param permission the permission to be removed from this entry.
-     * @return true if the permission is removed, false if the permission was 
not
-     *         part of this entry's permission set.
+     * @return true if the permission is removed, false if the permission was 
not part of this entry's permission set.
      */
-    public synchronized boolean removePermission( Permission permission )
-    {
-        Permission p = findPermission( permission );
-
-        if ( p != null )
-        {
+    public synchronized boolean removePermission( final Permission permission 
) {
+        final Permission p = findPermission( permission );
+        if( p != null ) {
             m_permissions.remove( p );
             return true;
         }
@@ -118,38 +107,34 @@ public class AclEntryImpl implements AclEntry, 
Serializable
     }
 
     /**
-     * Specifies the principal for which permissions are granted or denied by
-     * this ACL entry. If a principal was already set for this ACL entry, false
-     * is returned, otherwise true is returned.
+     * Specifies the principal for which permissions are granted or denied by 
this ACL entry. If a principal was already set for this ACL
+     * entry, false is returned, otherwise true is returned.
+     *
      * @param user the principal to be set for this entry
      * @return true if the principal is set, false if there was already a
-     *         principal set for this entry
+     * principal set for this entry
      */
-    public synchronized boolean setPrincipal( Principal user )
-    {
-        if ( m_principal != null || user == null )
+    public synchronized boolean setPrincipal( final Principal user ) {
+        if( m_principal != null || user == null ) {
             return false;
-
+        }
         m_principal = user;
-
         return true;
     }
 
     /**
      * Returns a string representation of the contents of this ACL entry.
+     *
      * @return a string representation of the contents.
      */
-    public String toString()
-    {
-       StringBuilder sb = new StringBuilder();
-
-        Principal p = getPrincipal();
-
-        sb.append( "[AclEntry ALLOW " + ( p != null ? p.getName() : "null" ) );
-        sb.append( " " );
-
-        for( Permission pp : m_permissions )
-        {
+    public String toString() {
+        final Principal p = getPrincipal();
+        final StringBuilder sb = new StringBuilder();
+        sb.append( "[AclEntry ALLOW " )
+          .append( p != null ? p.getName() : "null" )
+          .append( " " );
+
+        for( final Permission pp : m_permissions ) {
             sb.append( pp.toString() );
             sb.append( "," );
         }
@@ -163,17 +148,14 @@ public class AclEntryImpl implements AclEntry, 
Serializable
      * Looks through the permission list and finds a permission that matches 
the
      * permission.
      */
-    private Permission findPermission( Permission p )
-    {
-        for( Permission pp : m_permissions )
-        {
-            if ( pp.implies( p ) )
-            {
+    private Permission findPermission( final Permission p ) {
+        for( final Permission pp : m_permissions ) {
+            if( pp.implies( p ) ) {
                 return pp;
             }
         }
-
         return null;
     }
+
 }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/AclImpl.java 
b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/AclImpl.java
index 8688e0b..4ba1d62 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/AclImpl.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/AclImpl.java
@@ -23,7 +23,9 @@ import org.apache.wiki.api.core.AclEntry;
 import java.io.Serializable;
 import java.security.Permission;
 import java.security.Principal;
+import java.util.ArrayList;
 import java.util.Enumeration;
+import java.util.List;
 import java.util.Vector;
 
 
@@ -46,7 +48,7 @@ public class AclImpl implements Acl, Serializable {
     /** {@inheritDoc} */
     @Override
     public Principal[] findPrincipals( final Permission permission ) {
-        final Vector< Principal > principals = new Vector<>();
+        final List< Principal > principals = new ArrayList<>();
         final Enumeration< AclEntry > entries = aclEntries();
         while( entries.hasMoreElements() ) {
             final AclEntry entry = entries.nextElement();

Reply via email to