Package dev.orne.beans
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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull String[]
extractRequiredTokenBodyParts
(@NotNull String prefix, @NotNull String token, int expectedParts) Extracts the body parts of a token generated byAbstractComposedIdentity
.static @NotNull String[]
extractRequiredTokenBodyParts
(@NotNull String prefix, @NotNull String token, @NotNull String separator, int expectedParts) Extracts the body parts of a token generated byAbstractComposedIdentity
.static @NotNull String[]
extractRequiredTokenBodyParts
(@NotNull String prefix, @NotNull String token, @NotNull String separator, @NotNull String placeholder, int expectedParts) Extracts the body parts of a token generated byAbstractComposedIdentity
.static @NotNull String[]
extractTokenBodyParts
(@NotNull String prefix, @NotNull String token) Extracts theString
value of a token generated byStringIdentity
.static @NotNull String[]
extractTokenBodyParts
(@NotNull String prefix, @NotNull String token, @NotNull String separator) Extracts theString
value of a token generated byStringIdentity
.static @NotNull String[]
extractTokenBodyParts
(@NotNull String prefix, @NotNull String token, @NotNull String separator, @NotNull String placeholder) Extracts theString
value of a token generated byStringIdentity
.protected String
Returns the identity token body composed from the values of this identity.protected abstract @NotNull String[]
Returns the identity token body composed from the values of this identity.protected @NotNull String
Return the placeholder for null identity token parts.protected @NotNull String
Return the identity token body parts separator.Methods inherited from class dev.orne.beans.AbstractIdentity
equals, getIdentityToken, getIdentityTokenPrefix, hashCode, parseIdentityTokenBody, toString
-
Field Details
-
DEFAULT_SEPARATOR
Default identity token body parts separator.- See Also:
-
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
Returns the identity token body composed from the values of this identity. Equal instances must return equal identity token body.- Specified by:
getIdentityTokenBody
in classAbstractIdentity
- Returns:
- The identity token body for this instance
-
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
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
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 theString
value of a token generated byStringIdentity
.- Parameters:
prefix
- The expected identity token prefix.token
- The identity token.- Returns:
- The extracted identity token body parts.
- Throws:
NullPointerException
- If any argument isnull
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 theString
value of a token generated byStringIdentity
.- 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 isnull
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 theString
value of a token generated byStringIdentity
.- Parameters:
prefix
- The expected identity token prefix.token
- The identity token.separator
- The identity token body parts separator.placeholder
- Thenull
identity token body part placeholder.- Returns:
- The extracted identity token body parts.
- Throws:
NullPointerException
- If any argument isnull
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 byAbstractComposedIdentity
.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 isnull
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 byAbstractComposedIdentity
.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 isnull
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 byAbstractComposedIdentity
.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
- Thenull
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 isnull
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:
-