Class ColumnStructure<C>

java.lang.Object
com.ptsmods.mysqlw.table.ColumnStructure<C>
Type Parameters:
C - The type of the configurable used to get the typeString of the ColumnType used to create this structure.

public class ColumnStructure<C> extends Object
A structure used to describe a column.
Used when making new tables.
Acquire a ColumnStructure via ColumnType.struct() on any of the types in that class.
  • Method Details

    • getType

      public ColumnType<C> getType()
    • setTypeString

      public ColumnStructure<C> setTypeString(String typeString)
      Basically what configuring does, except you put in raw data.
      Don't forget to include the type in here too.
      Example: VARCHAR(255)
      Parameters:
      typeString - The new typeString.
      Returns:
      This structure
    • getTypeString

      @Nullable public @Nullable String getTypeString()
      Returns:
      The string set using configure(Function). Will return null unless setTypeString(String) has been called.
    • buildTypeString

      public String buildTypeString(Database.RDBMS type)
      Builds the type string for the given database type.
      Parameters:
      type -
      Returns:
    • satiateSupplier

      @Deprecated public ColumnStructure<C> satiateSupplier(Function<C,String> configurator)
      Deprecated.
      Has been renamed. Use configure(Function) instead.
      Run and return the value of the supplier of the selected ColumnType.

      THIS MUST BE RAN, UNLESS THE SUPPLIER IS AN INSTANCE OF Supplier.

      Parameters:
      configurator - The function that gets the supplier and returns its value.
      Returns:
      This structure
    • configure

      public ColumnStructure<C> configure(Function<C,String> configurator)
      Run and return the value of the supplier of the selected ColumnType.

      This must be called if the ColumnType of this structure has no default values set for its supplier.
      (This is the case for e.g. ENUM, SET, CHAR, VARCHAR)
      Parameters:
      configurator - The function that gets the supplier and returns its value.
      Returns:
      This structure
    • getSupplier

      @Deprecated public C getSupplier()
      Deprecated.
      Suppliers are now type-specific, please use getTypeSpecificSupplier() instead.
      Returns:
      The supplier that's used to configure this structure.
      See Also:
    • getTypeSpecificSupplier

      public Function<Database.RDBMS,C> getTypeSpecificSupplier()
      Returns:
      The supplier that may return a different output based on the RDBMS it's used for. Used to configure this structure.
    • setUnique

      public ColumnStructure<C> setUnique()
      Sets unique to true.
      Returns:
      This structure
      See Also:
    • setUnique

      public ColumnStructure<C> setUnique(boolean unique)
      Parameters:
      unique - Whether this column may only contain unique values.
      Returns:
      This structure
    • isUnique

      public boolean isUnique()
      Returns:
      Whether this column may only contain unique values.
    • setPrimary

      public ColumnStructure<C> setPrimary()
      Sets primary to true.
      Returns:
      This structure
      See Also:
    • setPrimary

      public ColumnStructure<C> setPrimary(boolean primary)
      Parameters:
      primary - Whether this column is the PRIMARY KEY of its table.
      Returns:
      This structure
    • isPrimary

      public boolean isPrimary()
      Returns:
      Whether this column is the PRIMARY KEY of its table.
    • setDefault

      public ColumnStructure<C> setDefault(@Nullable @Nullable ColumnDefault defValue)
      Parameters:
      defValue - The default value of this column, either NULL, CURRENT_TIMESTAMP or a custom default value.
      Returns:
      This structure
    • getDefValue

      public ColumnDefault getDefValue()
      Returns:
      The default value of this column, either NULL, CURRENT_TIMESTAMP or a custom default value.
    • setAttributes

      public ColumnStructure<C> setAttributes(@Nullable @Nullable ColumnAttributes attributes)
      Parameters:
      attributes - The attributes of the type of this column.
      Returns:
      This structure
    • getAttributes

      public ColumnAttributes getAttributes()
      Returns:
      The attributes of the type of this column.
    • setNullable

      public ColumnStructure<C> setNullable()
      Sets null allowed to true.
      Returns:
      This structure
      See Also:
    • setNonNull

      public ColumnStructure<C> setNonNull()
      Sets null allowed to false.
      Returns:
      This structure
      See Also:
    • setNullAllowed

      public ColumnStructure<C> setNullAllowed(boolean nullAllowed)
      Parameters:
      nullAllowed - Whether this column can contain null values.
      Returns:
      This structure
    • isNullAllowed

      public boolean isNullAllowed()
      Returns:
      Whether this column can contain null values.
    • setAutoIncrement

      public ColumnStructure<C> setAutoIncrement()
      Sets auto increment to true.
      Returns:
      This structure.
      See Also:
    • setAutoIncrement

      public ColumnStructure<C> setAutoIncrement(boolean autoIncrement)
      Parameters:
      autoIncrement - Whether the value of this column should be incremented by one for each row inserted.
      Returns:
      This structure.
    • isAutoIncrement

      public boolean isAutoIncrement()
      Returns:
      Whether the value of this column should be incremented by one for each row inserted.
    • setComment

      public ColumnStructure<C> setComment(@Nullable @Nullable String comment)
      Parameters:
      comment - The comment of this column. Used to describe what it's for.
      Returns:
      This structure
    • getComment

      public String getComment()
      Returns:
      The comment of this column. Used to describe what it's for.
    • setExtra

      public ColumnStructure<C> setExtra(@Nullable @Nullable String extra)
      Parameters:
      extra - Anything else you could possibly want to add that this class does not cover. It would also be appreciated if you could make a pull request or issue to cover this on the GitHub page.
      Returns:
      This structure
    • getExtra

      public String getExtra()
      Returns:
      Anything else you could possibly want to add that this class does not cover.
    • readOnly

      public ColumnStructure<C> readOnly()
      Makes this ColumnStructure immutable so it cannot be edited.
      Used when describing a table.
      Returns:
      This ColumnStructure
    • clone

      public ColumnStructure<C> clone()
      Overrides:
      clone in class Object
      Returns:
      A shallow copy of this structure.
    • toString

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

      public String toString(Database.RDBMS type)