Class RealmNestedPrincipal

  • All Implemented Interfaces:
    Serializable, Principal

    public final class RealmNestedPrincipal
    extends Object
    implements Principal, Serializable
    A principal type which is used to find a specific identity in a specific realm. This principal can be used to locate an exact identity whose name may have changed or may be unknown, but which can be located another way (for example, by primary key).
    Author:
    David M. Lloyd
    See Also:
    Serialized Form
    • Constructor Detail

      • RealmNestedPrincipal

        public RealmNestedPrincipal​(String realmName,
                                    Principal nestedPrincipal)
        Construct a new instance.
        Parameters:
        realmName - the realm name (must not be null)
        nestedPrincipal - the nested principal (must not be null)
    • Method Detail

      • getRealmName

        public String getRealmName()
        Get the realm name.
        Returns:
        the realm name (not null)
      • getNestedPrincipal

        public Principal getNestedPrincipal()
        Get the nested principal.
        Returns:
        the nested principal (not null)
      • getNestedPrincipal

        public <P extends Principal> P getNestedPrincipal​(Class<P> principalClass)
        Get the nested principal if it is of the given type class.
        Returns:
        the nested principal, or null if the nested principal is not of the given type
      • getName

        public String getName()
        Returns the name of this principal, which is composed of the realm name and the name of the nested principal.
        Specified by:
        getName in interface Principal
        Returns:
        the name of this principal
      • hashCode

        public int hashCode()
        Get the hash code of this principal.
        Specified by:
        hashCode in interface Principal
        Overrides:
        hashCode in class Object
        Returns:
        the hash code of this principal
      • equals

        public boolean equals​(Object obj)
        Determine whether this principal is equal to the given object.
        Specified by:
        equals in interface Principal
        Overrides:
        equals in class Object
        Parameters:
        obj - the object
        Returns:
        true if they are equal, false otherwise
      • equals

        public boolean equals​(RealmNestedPrincipal obj)
        Determine whether this principal is equal to the given object.
        Parameters:
        obj - the object
        Returns:
        true if they are equal, false otherwise
      • toString

        public String toString()
        Get this principal as a string.
        Specified by:
        toString in interface Principal
        Overrides:
        toString in class Object
        Returns:
        this principal as a string (not null)