Class AbstractIdentity

java.lang.Object
dev.orne.beans.AbstractIdentity
All Implemented Interfaces:
Identity, Serializable
Direct Known Subclasses:
AbstractComposedIdentity, AbstractSimpleIdentity

@API(status=STABLE, since="0.1") public abstract class AbstractIdentity extends Object implements Identity
Base abstract implementation for Identity. Manages the formatting and parsing of identity tokens.
Since:
0.1
Version:
1.0, 2020-05
Author:
(w) Iker Hernaez
See Also:
  • Constructor Details

    • AbstractIdentity

      protected AbstractIdentity()
      Creates a new instance.
  • Method Details

    • getIdentityTokenPrefix

      @NotNull @ValidIdentityTokenPrefix protected @NotNull String getIdentityTokenPrefix()
      Return the identity token prefix used for instances of this identity type. Must return same value for instances of the same class.
      Returns:
      The identity token prefix for this class
    • getIdentityTokenBody

      protected abstract String getIdentityTokenBody()
      Returns the identity token body composed from the values of this identity. Equal instances must return equal identity token body.
      Returns:
      The identity token body for this instance
    • parseIdentityTokenBody

      protected final String parseIdentityTokenBody(@NotNull @NotNull String token) throws UnrecognizedIdentityTokenException
      Parses the specified identity token and returns the original identity token body used during formatting.
      Parameters:
      token - The token identity
      Returns:
      The original token identity body
      Throws:
      UnrecognizedIdentityTokenException - If the identity token is not recognized
    • getIdentityToken

      @NotNull @ValidIdentityToken public @NotNull @ValidIdentityToken String getIdentityToken()
      Returns the identity token. This token must be unique among non equal instances of the same type of tokens.
      Specified by:
      getIdentityToken in interface Identity
      Returns:
      The identity token
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object