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
Modifier and TypeMethodDescriptionboolean
default boolean
areEqualStringValue
(String value, String another) Converts values from string and then performs equality checkingconvertFromString
(String stringRepresentation) Converts the value from string representation as produced byconvertToString(Object)
convertToString
(T value) Dumps a domain value to string.default T
deserializeSimple
(String value) Many attributes are passed in a string form, especially when obtained externally.default Optional<pl.edu.icm.unity.base.confirmation.EmailConfirmationConfiguration>
If syntax is verifiable by email return confirmation configurationdefault int
com.fasterxml.jackson.databind.JsonNode
int
boolean
boolean
default Optional<PublicAttributeSpec>
When non empty all attributes values with this syntax ban can be accessed publicly.default String
serializeSimple
(T value) Performs a simplified serialization of the value object to string.void
setSerializedConfiguration
(com.fasterxml.jackson.databind.JsonNode json) Initializesvoid
Validates the valuedefault void
validateStringValue
(String value) Converts value to string and then validates it
-
Method Details
-
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
String getValueSyntaxId()- Returns:
- attribute value syntax ID
-
validate
Validates the value- Parameters:
value
-- Throws:
pl.edu.icm.unity.base.attribute.IllegalAttributeValueException
-
validateStringValue
default void validateStringValue(String value) throws pl.edu.icm.unity.base.attribute.IllegalAttributeValueException Converts value to string and then validates it- Parameters:
value
-- Throws:
pl.edu.icm.unity.base.attribute.IllegalAttributeValueException
-
areEqual
- Parameters:
value
-another
-- Returns:
- true only if the two values are the same.
-
areEqualStringValue
Converts values from string and then performs equality checking- Parameters:
value
-another
-- Returns:
- true only if the two values are the same.
-
hashCode
- Parameters:
value
- , must be of T type, otherwise the standard hash should be returned.- Returns:
- java hashcode of the value
-
serializeSimple
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(String value) throws pl.edu.icm.unity.base.attribute.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.base.attribute.IllegalAttributeValueException
-
convertFromString
Converts the value from string representation as produced byconvertToString(Object)
- Parameters:
stringRepresentation
-- Returns:
- Throws:
pl.edu.icm.unity.base.attribute.IllegalAttributeValueException
- if the conversion can not be performed.
-
convertToString
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 Optional<pl.edu.icm.unity.base.confirmation.EmailConfirmationConfiguration> getEmailConfirmationConfiguration()If syntax is verifiable by email return confirmation configuration- Returns:
-
publicExposureSpec
When non empty all attributes values with this syntax ban can be accessed publicly.
-