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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String[]extractRequiredTokenBodyParts(String prefix, String token, int expectedParts) Extracts the body parts of a token generated byAbstractComposedIdentity.static String[]extractRequiredTokenBodyParts(String prefix, String token, String separator, int expectedParts) Extracts the body parts of a token generated byAbstractComposedIdentity.static String[]extractRequiredTokenBodyParts(String prefix, String token, String separator, String placeholder, int expectedParts) Extracts the body parts of a token generated byAbstractComposedIdentity.static String[]extractTokenBodyParts(String prefix, String token) Extracts theStringvalue of a token generated byStringIdentity.static String[]extractTokenBodyParts(String prefix, String token, String separator) Extracts theStringvalue of a token generated byStringIdentity.static String[]extractTokenBodyParts(String prefix, String token, String separator, String placeholder) Extracts theStringvalue of a token generated byStringIdentity.protected @Nullable StringReturns the identity token body composed from the values of this identity.protected abstract String[]Returns the identity token body composed from the values of this identity.protected StringReturn the placeholder for null identity token parts.protected StringReturn 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:
getIdentityTokenBodyin 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
Extracts theStringvalue 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 isnullUnrecognizedIdentityTokenException- If the identity token is not a valid simple identity token or if it doesn't start with the expected prefix.- See Also:
-
extractTokenBodyParts
Extracts theStringvalue 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 isnullUnrecognizedIdentityTokenException- If the identity token is not a valid simple identity token or if it doesn't start with the expected prefix.- See Also:
-
extractTokenBodyParts
public static String[] extractTokenBodyParts(String prefix, String token, String separator, String placeholder) Extracts theStringvalue of a token generated byStringIdentity.- Parameters:
prefix- The expected identity token prefix.token- The identity token.separator- The identity token body parts separator.placeholder- Thenullidentity token body part placeholder.- Returns:
- The extracted identity token body parts.
- Throws:
NullPointerException- If any argument isnullUnrecognizedIdentityTokenException- If the identity token is not a valid simple identity token or if it doesn't start with the expected prefix.
-
extractRequiredTokenBodyParts
public static String[] extractRequiredTokenBodyParts(String prefix, String token, int expectedParts) Extracts the body parts of a token generated byAbstractComposedIdentity.If the resulting value is
nullor 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 isnullUnrecognizedIdentityTokenException- 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
public static String[] extractRequiredTokenBodyParts(String prefix, String token, String separator, int expectedParts) Extracts the body parts of a token generated byAbstractComposedIdentity.If the resulting value is
nullor 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 isnullUnrecognizedIdentityTokenException- 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
public static String[] extractRequiredTokenBodyParts(String prefix, String token, String separator, String placeholder, int expectedParts) Extracts the body parts of a token generated byAbstractComposedIdentity.If the resulting value is
nullor 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- Thenullidentity token body part placeholder.expectedParts- The expected identity token body parts count.- Returns:
- The extracted identity token body parts.
- Throws:
NullPointerException- If any argument isnullUnrecognizedIdentityTokenException- 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:
-