java.lang.Object
com.cryptoalgo.oursql.model.db.data.Container<T>
Direct Known Subclasses:
BitContainer, BooleanContainer, NumberContainer, PlaceholderContainer, StringContainer, TIDContainer

public abstract class Container<T> extends Object
An immutable "box" for holding different types of data
  • Field Details

    • value

      protected final T value
      Value stored in container
  • Constructor Details

    • Container

      public Container(String val)
      Default constructor that unboxes a raw string value into the container
      Parameters:
      val - Raw string value to unbox
  • Method Details

    • getValue

      public T getValue()
      Get the stored value in this container
      Returns:
      The stored value in this container
    • getFinalValue

      public String getFinalValue(String input)
      Get the final value from a user input for committing
      Parameters:
      input - Raw input
      Returns:
      Output to be used for the commit operation
    • unbox

      protected abstract T unbox(String val)
      "Unbox" a raw string to the boxed type
      Parameters:
      val - Raw string for unboxing
      Returns:
      Boxed type representing the string
    • isValid

      public abstract boolean isValid(String value)
      Parameters:
      value - Value to be checked
      Returns:
      true if value can be cast to the type of this container
    • isEditable

      public boolean isEditable()
      Returns:
      True if editing fields of this container type should be allowed
    • getTypes

      public static String[] getTypes()
      Get supported SQL types
      Returns:
      A string array of supported SQL types
    • getInstance

      @Nullable public static @Nullable Class<? extends Container<?>> getInstance(String forType)
      Parameters:
      forType - SQL type to get container fo
      Returns:
      Container class appropriate for type
    • toString

      public abstract String toString()
      Overrides:
      toString in class Object
    • toSQLString

      public String toSQLString()
      Get an escaped string representation of the value in this container. Value contained should be escaped and ready for insertion into a SQL query.
      Returns:
      Escaped string representation of the value in this container