org.apache.wicket.authorization.strategies.role
Class Roles

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by java.util.HashSet<java.lang.String>
              extended by org.apache.wicket.authorization.strategies.role.Roles
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<java.lang.String>, java.util.Collection<java.lang.String>, java.util.Set<java.lang.String>, IClusterable

public final class Roles
extends java.util.HashSet<java.lang.String>
implements IClusterable

Utility class for working with roles.

Author:
Eelco Hillenius, Jonathan Locke
See Also:
Serialized Form

Field Summary
static java.lang.String ADMIN
          ADMIN role (for use in annotations)
static java.lang.String USER
          USER role (for use in annotations)
 
Constructor Summary
Roles()
          Construct.
Roles(java.lang.String roles)
          Construct.
Roles(java.lang.String[] roles)
          Construct.
 
Method Summary
 boolean hasAllRoles(Roles roles)
          Whether this roles object contains all the provided roles.
 boolean hasAnyRole(Roles roles)
          Whether this roles object contains any of the provided roles.
 boolean hasRole(java.lang.String role)
          Whether this roles object containes the provided role.
 java.lang.String toString()
           
 
Methods inherited from class java.util.HashSet
add, clear, clone, contains, isEmpty, iterator, remove, size
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
 

Field Detail

USER

public static final java.lang.String USER
USER role (for use in annotations)

See Also:
Constant Field Values

ADMIN

public static final java.lang.String ADMIN
ADMIN role (for use in annotations)

See Also:
Constant Field Values
Constructor Detail

Roles

public Roles()
Construct.


Roles

public Roles(java.lang.String roles)
Construct.

Parameters:
roles - Roles as a comma separated list, like "ADMIN, USER"

Roles

public Roles(java.lang.String[] roles)
Construct.

Parameters:
roles - Roles
Method Detail

hasRole

public boolean hasRole(java.lang.String role)
Whether this roles object containes the provided role.

Parameters:
role - the role to check
Returns:
true if it contains the role, false otherwise

hasAnyRole

public boolean hasAnyRole(Roles roles)
Whether this roles object contains any of the provided roles.

Parameters:
roles - the roles to check
Returns:
true if it contains any of the roles, false otherwise

hasAllRoles

public boolean hasAllRoles(Roles roles)
Whether this roles object contains all the provided roles.

Parameters:
roles - the roles to check
Returns:
true if it contains all the roles or the provided roles object is null, false otherwise

toString

public java.lang.String toString()
Overrides:
toString in class java.util.AbstractCollection<java.lang.String>
See Also:
Object.toString()


Copyright © 2004-2010 Apache Software Foundation. All Rights Reserved.