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 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

      void validate(T value) throws IllegalAttributeValueException
      Validates the value
      Parameters:
      value -
      Throws:
      IllegalAttributeValueException
    • validateStringValue

      default void validateStringValue(String value) throws IllegalAttributeValueException
      Converts value to string and then validates it
      Parameters:
      value -
      Throws:
      IllegalAttributeValueException
    • areEqual

      boolean areEqual(T value, Object another)
      Parameters:
      value -
      another -
      Returns:
      true only if the two values are the same.
    • areEqualStringValue

      default boolean areEqualStringValue(String value, 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(Object value)
      Parameters:
      value - , must be of T type, otherwise the standard hash should be returned.
      Returns:
      java hashcode of the value
    • serializeSimple

      default 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(String value) throws 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:
      IllegalAttributeValueException
    • convertFromString

      T convertFromString(String stringRepresentation)
      Converts the value from string representation as produced by convertToString(Object)
      Parameters:
      stringRepresentation -
      Returns:
      Throws:
      IllegalAttributeValueException - if the conversion can not be performed.
    • convertToString

      String convertToString(T value)
      Dumps a domain value to string. This method (conversly to serializeSimple(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<EmailConfirmationConfiguration> getEmailConfirmationConfiguration()
      If syntax is verifiable by email return confirmation configuration
      Returns:
    • publicExposureSpec

      default Optional<PublicAttributeSpec> publicExposureSpec()
      When non empty all attributes values with this syntax ban can be accessed publicly.