Class AbstractComposedIdentity

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

@API(status=MAINTAINED, since="0.5") public abstract class AbstractComposedIdentity extends AbstractIdentity
Abstract implementation for Identity for identities composed of a multiple inner values.
Since:
0.5
Version:
1.0, 2023-05
Author:
(w) Iker Hernaez
See Also:
  • Field Details

    • DEFAULT_SEPARATOR

      public static final String DEFAULT_SEPARATOR
      Default identity token body parts separator.
      See Also:
    • DEFAULT_NULL_PLACEHOLDER

      public static final String DEFAULT_NULL_PLACEHOLDER
      The default placeholder for null identity token parts.
      See Also:
  • Constructor Details

    • AbstractComposedIdentity

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

    • getIdentityTokenBody

      protected String getIdentityTokenBody()
      Returns the identity token body composed from the values of this identity. Equal instances must return equal identity token body.
      Specified by:
      getIdentityTokenBody in class AbstractIdentity
      Returns:
      The identity token body for this instance
    • getIdentityTokenBodyParts

      @NotNull protected abstract @NotNull String[] getIdentityTokenBodyParts()
      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
    • getIdentityTokenBodyPartsSeparator

      @NotNull protected @NotNull String getIdentityTokenBodyPartsSeparator()
      Return the identity token body parts separator. Must return same value for instances of the same class.
      Returns:
      The identity token body parts separator.
    • getIdentityTokenBodyPartsNullPlaceholder

      @NotNull protected @NotNull String getIdentityTokenBodyPartsNullPlaceholder()
      Return the placeholder for null identity token parts. Must return same value for instances of the same class.
      Returns:
      The placeholder for null identity token parts.
    • extractTokenBodyParts

      @NotNull public static @NotNull String[] extractTokenBodyParts(@NotNull @NotNull String prefix, @NotNull @NotNull String token)
      Extracts the String value of a token generated by StringIdentity.
      Parameters:
      prefix - The expected identity token prefix.
      token - The identity token.
      Returns:
      The extracted identity token body parts.
      Throws:
      NullPointerException - If any argument is null
      UnrecognizedIdentityTokenException - If the identity token is not a valid simple identity token or if it doesn't start with the expected prefix.
      See Also:
    • extractTokenBodyParts

      @NotNull public static @NotNull String[] extractTokenBodyParts(@NotNull @NotNull String prefix, @NotNull @NotNull String token, @NotNull @NotNull String separator)
      Extracts the String value of a token generated by StringIdentity.
      Parameters:
      prefix - The expected identity token prefix.
      token - The identity token.
      separator - The identity token body parts separator.
      Returns:
      The extracted identity token body parts.
      Throws:
      NullPointerException - If any argument is null
      UnrecognizedIdentityTokenException - If the identity token is not a valid simple identity token or if it doesn't start with the expected prefix.
      See Also:
    • extractTokenBodyParts

      @NotNull public static @NotNull String[] extractTokenBodyParts(@NotNull @NotNull String prefix, @NotNull @NotNull String token, @NotNull @NotNull String separator, @NotNull @NotNull String placeholder)
      Extracts the String value of a token generated by StringIdentity.
      Parameters:
      prefix - The expected identity token prefix.
      token - The identity token.
      separator - The identity token body parts separator.
      placeholder - The null identity token body part placeholder.
      Returns:
      The extracted identity token body parts.
      Throws:
      NullPointerException - If any argument is null
      UnrecognizedIdentityTokenException - If the identity token is not a valid simple identity token or if it doesn't start with the expected prefix.
    • extractRequiredTokenBodyParts

      @NotNull public static @NotNull String[] extractRequiredTokenBodyParts(@NotNull @NotNull String prefix, @NotNull @NotNull String token, int expectedParts)
      Extracts the body parts of a token generated by AbstractComposedIdentity.

      If the resulting value is null or the body parts count is not the expected one an exception is thrown.

      Parameters:
      prefix - The expected identity token prefix.
      token - The identity token.
      expectedParts - The expected identity token body parts count.
      Returns:
      The extracted identity token body parts.
      Throws:
      NullPointerException - If any argument is null
      UnrecognizedIdentityTokenException - If the identity token is not a valid identity token, if it doesn't start with the expected prefix, if the extracted body is null or the extracted body parts count does not match the expected parts count.
      See Also:
    • extractRequiredTokenBodyParts

      @NotNull public static @NotNull String[] extractRequiredTokenBodyParts(@NotNull @NotNull String prefix, @NotNull @NotNull String token, @NotNull @NotNull String separator, int expectedParts)
      Extracts the body parts of a token generated by AbstractComposedIdentity.

      If the resulting value is null or the body parts count is not the expected one an exception is thrown.

      Parameters:
      prefix - The expected identity token prefix.
      token - The identity token.
      separator - The identity token body parts separator.
      expectedParts - The expected identity token body parts count.
      Returns:
      The extracted identity token body parts.
      Throws:
      NullPointerException - If any argument is null
      UnrecognizedIdentityTokenException - If the identity token is not a valid identity token, if it doesn't start with the expected prefix, if the extracted body is null or the extracted body parts count does not match the expected parts count.
      See Also:
    • extractRequiredTokenBodyParts

      @NotNull public static @NotNull String[] extractRequiredTokenBodyParts(@NotNull @NotNull String prefix, @NotNull @NotNull String token, @NotNull @NotNull String separator, @NotNull @NotNull String placeholder, int expectedParts)
      Extracts the body parts of a token generated by AbstractComposedIdentity.

      If the resulting value is null or the body parts count is not the expected one an exception is thrown.

      Parameters:
      prefix - The expected identity token prefix.
      token - The identity token.
      separator - The identity token body parts separator.
      placeholder - The null identity token body part placeholder.
      expectedParts - The expected identity token body parts count.
      Returns:
      The extracted identity token body parts.
      Throws:
      NullPointerException - If any argument is null
      UnrecognizedIdentityTokenException - If the identity token is not a valid identity token, if it doesn't start with the expected prefix, if the extracted body is null or the extracted body parts count does not match the expected parts count.
      See Also: