Interface AttributeValueSyntax<T>
-
public interface AttributeValueSyntax<T>
Base interface defining attribute value syntax. It provides handling of the configuration (typically used server side to validate values), (de)serialization to String and equality test.Note that validation is only meaningful when the implementation was properly populated with configuration.
- Author:
- K. Benedyczak
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
areEqual(T value, java.lang.Object another)
default boolean
areEqualStringValue(java.lang.String value, java.lang.String another)
Converts values from string and then performs equality checkingT
convertFromString(java.lang.String stringRepresentation)
Converts the value from string representation as produced byconvertToString(Object)
java.lang.String
convertToString(T value)
Dumps a domain value to string.default T
deserializeSimple(java.lang.String value)
Many attributes are passed in a string form, especially when obtained externally.default java.util.Optional<pl.edu.icm.unity.types.confirmation.EmailConfirmationConfiguration>
getEmailConfirmationConfiguration()
If syntax is verifiable by email return confirmation configurationdefault int
getMaxSize()
com.fasterxml.jackson.databind.JsonNode
getSerializedConfiguration()
java.lang.String
getValueSyntaxId()
int
hashCode(java.lang.Object value)
boolean
isEmailVerifiable()
boolean
isUserVerifiable()
default java.util.Optional<PublicAttributeSpec>
publicExposureSpec()
When non empty all attributes values with this syntax ban can be accessed publicly.default java.lang.String
serializeSimple(T value)
Performs a simplified serialization of the value object to string.void
setSerializedConfiguration(com.fasterxml.jackson.databind.JsonNode json)
Initializesvoid
validate(T value)
Validates the valuedefault void
validateStringValue(java.lang.String value)
Converts value to string and then validates it
-
-
-
Method Detail
-
getSerializedConfiguration
com.fasterxml.jackson.databind.JsonNode getSerializedConfiguration()
- Returns:
- current serialized configuration of the syntax
-
setSerializedConfiguration
void setSerializedConfiguration(com.fasterxml.jackson.databind.JsonNode json)
Initializes- Parameters:
json
-
-
getValueSyntaxId
java.lang.String getValueSyntaxId()
- Returns:
- attribute value syntax ID
-
validate
void validate(T value) throws pl.edu.icm.unity.exceptions.IllegalAttributeValueException
Validates the value- Parameters:
value
-- Throws:
pl.edu.icm.unity.exceptions.IllegalAttributeValueException
-
validateStringValue
default void validateStringValue(java.lang.String value) throws pl.edu.icm.unity.exceptions.IllegalAttributeValueException
Converts value to string and then validates it- Parameters:
value
-- Throws:
pl.edu.icm.unity.exceptions.IllegalAttributeValueException
-
areEqual
boolean areEqual(T value, java.lang.Object another)
- Parameters:
value
-another
-- Returns:
- true only if the two values are the same.
-
areEqualStringValue
default boolean areEqualStringValue(java.lang.String value, java.lang.String another)
Converts values from string and then performs equality checking- Parameters:
value
-another
-- Returns:
- true only if the two values are the same.
-
hashCode
int hashCode(java.lang.Object value)
- Parameters:
value
- , must be of T type, otherwise the standard hash should be returned.- Returns:
- java hashcode of the value
-
serializeSimple
default java.lang.String serializeSimple(T value)
Performs a simplified serialization of the value object to string. Note that some of the information may be lost during this serialization: it is intended for exporting the value to outside world, so the value must be simple. For instance verifiable email will be serialized as an email address string, without confirmation information.- Parameters:
domain
- object- Returns:
- value in the string form, possibly simplified
-
deserializeSimple
default T deserializeSimple(java.lang.String value) throws pl.edu.icm.unity.exceptions.IllegalAttributeValueException
Many attributes are passed in a string form, especially when obtained externally. Whenever it is possible this method should convert string representation to the domain object. Note that this method may not be able to initialize all properties of the domain value object.- Parameters:
value
- to deserialize- Returns:
- domain object
- Throws:
pl.edu.icm.unity.exceptions.IllegalAttributeValueException
-
convertFromString
T convertFromString(java.lang.String stringRepresentation)
Converts the value from string representation as produced byconvertToString(Object)
- Parameters:
stringRepresentation
-- Returns:
- Throws:
pl.edu.icm.unity.exceptions.IllegalAttributeValueException
- if the conversion can not be performed.
-
convertToString
java.lang.String convertToString(T value)
Dumps a domain value to string. This method (conversly toserializeSimple(Object)
) must output a complete value.- Parameters:
value
-- Returns:
- value converted to string.
-
isEmailVerifiable
boolean isEmailVerifiable()
- Returns:
- true if values can be confirmed by user using out-of bounds verification (via email)
Note that if this method returns true then
isUserVerifiable()
must also return true
-
isUserVerifiable
boolean isUserVerifiable()
- Returns:
- true if values are implementing VerifiableElement and can be in confirmed or not state
-
getMaxSize
default int getMaxSize()
- Returns:
- max size of attribute values
-
getEmailConfirmationConfiguration
default java.util.Optional<pl.edu.icm.unity.types.confirmation.EmailConfirmationConfiguration> getEmailConfirmationConfiguration()
If syntax is verifiable by email return confirmation configuration- Returns:
-
publicExposureSpec
default java.util.Optional<PublicAttributeSpec> publicExposureSpec()
When non empty all attributes values with this syntax ban can be accessed publicly.
-
-