You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2005/09/16 11:05:07 UTC
svn commit: r289445 -
/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserClass.java
Author: trustin
Date: Fri Sep 16 02:05:04 2005
New Revision: 289445
URL: http://svn.apache.org/viewcvs?rev=289445&view=rev
Log:
Modified the API as Ersin requested to me.
* No add and remove methods
* All input comes as constructor parameters
Modified:
directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserClass.java
Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserClass.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserClass.java?rev=289445&r1=289444&r2=289445&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserClass.java (original)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserClass.java Fri Sep 16 02:05:04 2005
@@ -19,8 +19,13 @@
package org.apache.ldap.common.acl;
import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
-import org.apache.ldap.common.name.LdapName;
import org.apache.ldap.common.subtree.SubtreeSpecification;
public abstract class UserClass implements Serializable
@@ -62,16 +67,24 @@
private static abstract class NamedUserClass extends UserClass
{
- protected final LdapName name;
+ protected final Set names;
- protected NamedUserClass( LdapName name )
+ protected NamedUserClass( Set names )
{
- this.name = ( LdapName ) name.clone();
+ for( Iterator i = names.iterator(); i.hasNext(); )
+ {
+ Object val = i.next();
+ if( !( val instanceof Name ) )
+ {
+ throw new IllegalArgumentException( "names contains a wrong element." );
+ }
+ }
+ this.names = Collections.unmodifiableSet( new HashSet( names ) );
}
- public LdapName getName()
+ public Set getNames()
{
- return ( LdapName ) name.clone();
+ return names;
}
public boolean equals( Object o )
@@ -89,7 +102,7 @@
if( getClass().isAssignableFrom( o.getClass() ) )
{
Name that = ( Name ) o;
- return this.name.equals( that.name );
+ return this.names.equals( that.names );
}
return false;
@@ -97,7 +110,7 @@
public String toString()
{
- return name.toString();
+ return names.toString();
}
}
@@ -105,9 +118,9 @@
{
private static final long serialVersionUID = -4168412030168359882L;
- public Name( LdapName username )
+ public Name( Set usernames )
{
- super( username );
+ super( usernames );
}
public String toString()
@@ -120,9 +133,9 @@
{
private static final long serialVersionUID = 8887107815072965807L;
- public UserGroup( LdapName groupName )
+ public UserGroup( Set groupNames )
{
- super( groupName );
+ super( groupNames );
}
public String toString()
@@ -135,20 +148,24 @@
{
private static final long serialVersionUID = 3949337699049701332L;
- protected final SubtreeSpecification subtreeSpecification;
+ protected final Collection subtreeSpecifications;
- protected Subtree( SubtreeSpecification subtreeSpec )
+ protected Subtree( Collection subtreeSpecs )
{
- if( subtreeSpec == null )
+ for( Iterator i = subtreeSpecs.iterator(); i.hasNext(); )
{
- throw new NullPointerException( "subtreeSpec" );
+ Object val = i.next();
+ if( !( val instanceof SubtreeSpecification ) )
+ {
+ throw new IllegalArgumentException( "subtreeSpecs contains a wrong element." );
+ }
}
- this.subtreeSpecification = subtreeSpec;
+ this.subtreeSpecifications = Collections.unmodifiableCollection( new ArrayList( subtreeSpecs ) );
}
- public SubtreeSpecification getSubtreeSpecification()
+ public Collection getSubtreeSpecifications()
{
- return subtreeSpecification;
+ return subtreeSpecifications;
}
public boolean equals( Object o )
@@ -161,7 +178,7 @@
if( o instanceof Subtree )
{
Subtree that = ( Subtree ) o;
- return this.subtreeSpecification.equals( that.subtreeSpecification );
+ return this.subtreeSpecifications.equals( that.subtreeSpecifications );
}
return false;
@@ -169,7 +186,7 @@
public String toString()
{
- return "subtree: " + subtreeSpecification;
+ return "subtree: " + subtreeSpecifications;
}
}
}