Class EntityIdConverter

  • All Implemented Interfaces:
    javax.json.bind.adapter.JsonbAdapter<EntityId,​String>

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

      • EntityIdConverter

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

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