Class AbstractTypeHandler<T>

java.lang.Object
pro.cyberyon.mojet.types.AbstractTypeHandler<T>
Type Parameters:
T - type of pojo record
All Implemented Interfaces:
TypeHandler<T>

public abstract class AbstractTypeHandler<T> extends Object implements TypeHandler<T>
partial implementation to every concret TypeHandler.
Author:
Guillaume CHAUVET
  • Constructor Details

    • AbstractTypeHandler

      public AbstractTypeHandler()
  • Method Details

    • accept

      public final boolean accept(Class<?> type)
      Description copied from interface: TypeHandler
      Check if we can handle the data type
      Specified by:
      accept in interface TypeHandler<T>
      Parameters:
      type - to check
      Returns:
      true if handlable
    • read

      public final T read(String data, String format)
      Description copied from interface: TypeHandler
      process an input string to a concrete field value
      Specified by:
      read in interface TypeHandler<T>
      Parameters:
      data - string of data
      format - of data, null otherwise
      Returns:
      instance of the type
    • write

      public String write(T data, String format)
      Description copied from interface: TypeHandler
      transform a field value to an output string
      Specified by:
      write in interface TypeHandler<T>
      Parameters:
      data - the type with data
      format - of data, null otherwise
      Returns:
      string content of type
    • isAccept

      protected abstract boolean isAccept(Class<?> type)
      Check type of field (or nested type array)
      Parameters:
      type - non primitive class type to check
      Returns:
      positive if accepted
    • doRead

      protected abstract T doRead(@NonNull @NonNull String data, String format)
      Read a non null data
      Parameters:
      data - the data to read
      format - the optional format
      Returns:
      readed content
    • doWrite

      protected abstract String doWrite(@NonNull T data, String format)
      Write a non null data
      Parameters:
      data - the data to write
      format - the optional format
      Returns:
      content to write