directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject [4/6] git commit: o Added the toString() method o Added some Javadoc o A bit of refactoring
Date Wed, 29 Oct 2014 16:10:28 GMT
o Added the toString() method
o Added some Javadoc
o A bit of refactoring

Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/a4c5e213
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/a4c5e213
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/a4c5e213

Branch: refs/heads/master
Commit: a4c5e213d00a690f02d4e2bab78fdc1c08ffb156
Parents: 9bb82e6
Author: Emmanuel L├ęcharny <elecharny@symas.com>
Authored: Wed Oct 29 14:44:04 2014 +0100
Committer: Emmanuel L├ęcharny <elecharny@symas.com>
Committed: Wed Oct 29 14:44:04 2014 +0100

----------------------------------------------------------------------
 .../directory/fortress/core/rbac/OrgUnit.java   | 98 +++++++++++++++++++-
 1 file changed, 94 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a4c5e213/src/main/java/org/apache/directory/fortress/core/rbac/OrgUnit.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/OrgUnit.java b/src/main/java/org/apache/directory/fortress/core/rbac/OrgUnit.java
index a1db133..a975e5b 100755
--- a/src/main/java/org/apache/directory/fortress/core/rbac/OrgUnit.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/OrgUnit.java
@@ -20,6 +20,7 @@
 package org.apache.directory.fortress.core.rbac;
 
 
+import java.io.Serializable;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.UUID;
@@ -161,19 +162,30 @@ import javax.xml.bind.annotation.XmlType;
         "parents",
         "type"
 })
-public class OrgUnit extends FortEntity
-    implements Graphable, java.io.Serializable
+public class OrgUnit extends FortEntity implements Graphable, Serializable
 {
+    private static final long serialVersionUID = 1L;
+
     /**
-     * Maps to the location for a particular OrgUnit entity to either the User, {@code ou=OS-U},
or Permission, {@code ou=OS-P}, tree in ldap.
-     *
+     * Maps to the location for a particular OrgUnit entity to either the User, 
+     * {@code ou=OS-U}, or Permission, {@code ou=OS-P}, tree in ldap.
      */
     public Type type;
+    
+    /** The name required attribute of the OrgUnit object */
     private String name;
+    
+    /** the internal id that is associated with OrgUnit */
     private String id;
+    
+    /** The description that is associated with OrgUnit */
     private String description;
+    
+    /** The names of orgUnits that are parents (direct ascendants) of this orgUnit */
     @XmlElement(nillable = true)
     private Set<String> parents;
+    
+    /** The set of child orgUnit names (direct descendants) of this orgUnit */
     @XmlElement(nillable = true)
     private Set<String> children;
 
@@ -359,6 +371,7 @@ public class OrgUnit extends FortEntity
         {
             this.parents = new HashSet<>();
         }
+        
         this.parents.add( parent );
     }
 
@@ -403,14 +416,91 @@ public class OrgUnit extends FortEntity
     public boolean equals( Object thatObj )
     {
         if ( this == thatObj )
+        {
             return true;
+        }
+        
         if ( this.getName() == null )
+        {
             return false;
+        }
+        
         if ( !( thatObj instanceof OrgUnit ) )
+        {
             return false;
+        }
+        
         OrgUnit thatOrg = ( OrgUnit ) thatObj;
+        
         if ( thatOrg.getName() == null )
+        {
             return false;
+        }
+        
         return thatOrg.getName().equalsIgnoreCase( this.getName() );
     }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( "OrgUnit object: \n" );
+
+        sb.append( "    name :" ).append( name ).append( '\n' );
+        sb.append( "    id :" ).append( id ).append( '\n' );
+        sb.append( "    description :" ).append( description ).append( '\n' );
+        sb.append( "    type :" ).append( type ).append( '\n' );
+
+        if ( parents != null )
+        {
+            sb.append( "    parents : " );
+
+            boolean isFirst = true;
+
+            for ( String parent : parents )
+            {
+                if ( isFirst )
+                {
+                    isFirst = false;
+                }
+                else
+                {
+                    sb.append( ", " );
+                }
+
+                sb.append( parent );
+            }
+
+            sb.append( '\n' );
+        }
+
+        if ( children != null )
+        {
+            sb.append( "    children : " );
+
+            boolean isFirst = true;
+
+            for ( String child : children )
+            {
+                if ( isFirst )
+                {
+                    isFirst = false;
+                }
+                else
+                {
+                    sb.append( ", " );
+                }
+
+                sb.append( child );
+            }
+
+            sb.append( '\n' );
+        }
+
+        return sb.toString();
+    }
 }


Mime
View raw message