Class NumericPrincipal
- java.lang.Object
-
- org.wildfly.security.auth.principal.NumericPrincipal
-
- All Implemented Interfaces:
Serializable
,Principal
public final class NumericPrincipal extends Object implements Principal, Serializable
A principal which is represented by a numeric ID, such as what a database might use for a primary key.- Author:
- David M. Lloyd
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description NumericPrincipal(long id)
Construct a new instance.NumericPrincipal(String id)
Construct a new instance from a decimal string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Determine whether this principal is equal to the given object.boolean
equals(NumericPrincipal obj)
Determine whether this principal is equal to the given object.long
getId()
Get the ID of the principal.String
getName()
Returns the name of this principal, which is just the string representation of the ID.int
hashCode()
Get the hash code of this principal.String
toString()
Get this principal as a string.
-
-
-
Constructor Detail
-
NumericPrincipal
public NumericPrincipal(long id)
Construct a new instance.- Parameters:
id
- the ID of the principal
-
NumericPrincipal
public NumericPrincipal(String id) throws NumberFormatException
Construct a new instance from a decimal string.- Parameters:
id
- the ID of the principal, as a string- Throws:
NumberFormatException
- if the number is not a valid non-negative long integer
-
-
Method Detail
-
getId
public long getId()
Get the ID of the principal.- Returns:
- the ID of the principal
-
equals
public boolean equals(Object obj)
Determine whether this principal is equal to the given object.
-
equals
public boolean equals(NumericPrincipal obj)
Determine whether this principal is equal to the given object.- Parameters:
obj
- the object- Returns:
true
if they are equal,false
otherwise
-
hashCode
public int hashCode()
Get the hash code of this principal.
-
toString
public String toString()
Get this principal as a string.
-
-