Class EntityIdConverter

java.lang.Object
jakarta.xml.bind.annotation.adapters.XmlAdapter<String,EntityId>
org.fuin.ddd4j.ddd.EntityIdConverter
All Implemented Interfaces:
jakarta.json.bind.adapter.JsonbAdapter<EntityId,String>

@ThreadSafe public final class EntityIdConverter extends jakarta.xml.bind.annotation.adapters.XmlAdapter<String,EntityId> implements jakarta.json.bind.adapter.JsonbAdapter<EntityId,String>
JAXB and JSON converter for an entity identifier.
  • Constructor Details

    • EntityIdConverter

      public EntityIdConverter(EntityIdFactory factory)
      Constructor with factory.
      Parameters:
      factory - Factory to use.
  • Method Details

    • isValid

      public final boolean isValid(String value)
      Verifies that the given value can be converted into a value object using the factory. A null parameter will return true.
      Parameters:
      value - Value to check.
      Returns:
      true if the value can be converted, else false.
    • requireArgValid

      public final void requireArgValid(@NotNull @NotNull String name, @NotNull @NotNull String value) throws org.fuin.objects4j.common.ConstraintViolationException
      Verifies if the argument is valid and throws an exception if this is not the case.
      Parameters:
      name - Name of the value for a possible error message.
      value - Value to check.
      Throws:
      org.fuin.objects4j.common.ConstraintViolationException - The value was not valid.
    • toVO

      public final EntityId toVO(String value)
      Converts a string into an entity identifier. A null parameter will return null.
      Parameters:
      value - Representation of the entity identifier as string.
      Returns:
      Value object.
    • fromVO

      public final String fromVO(EntityId value)
      Converts the value object into a String. A null parameter will return null.
      Parameters:
      value - Value object.
      Returns:
      Base type.
    • marshal

      public final String marshal(EntityId value) throws Exception
      Specified by:
      marshal in class jakarta.xml.bind.annotation.adapters.XmlAdapter<String,EntityId>
      Throws:
      Exception
    • unmarshal

      public final EntityId unmarshal(String value) throws Exception
      Specified by:
      unmarshal in class jakarta.xml.bind.annotation.adapters.XmlAdapter<String,EntityId>
      Throws:
      Exception
    • adaptToJson

      public final String adaptToJson(EntityId obj) throws Exception
      Specified by:
      adaptToJson in interface jakarta.json.bind.adapter.JsonbAdapter<EntityId,String>
      Throws:
      Exception
    • adaptFromJson

      public final EntityId adaptFromJson(String str) throws Exception
      Specified by:
      adaptFromJson in interface jakarta.json.bind.adapter.JsonbAdapter<EntityId,String>
      Throws:
      Exception