Class Column

    • Constructor Detail

      • Column

        public Column​(String name,
                      String type)
        Instantiates a new Column.
        Parameters:
        name - the name of the column
        type - the data type of the column
      • Column

        public Column​(String name,
                      String type,
                      @NonNull
                      @NonNull Collection<Constraint> constraints)
        Instantiates a new Column.
        Parameters:
        name - the name of the column
        type - the data type of the column
        constraints - the column constraints
    • Method Detail

      • asStored

        public Column asStored​(SQLElement element)
        Sets a value that is auto generated for the column on insertion time and is stored in the database.
        Parameters:
        element - the element / expression to generate the column's value
        Returns:
        this column
      • asVirtual

        public Column asVirtual​(SQLElement element)
        Sets a value that is auto generated for the column on query time and not stored in the database.
        Parameters:
        element - the element / expression to generate the column's value
        Returns:
        this column
      • autoIncrement

        public Column autoIncrement()
        Sets this column as having its value auto incremented on assertion.
        Returns:
        this column
      • autoIncrement

        public Column autoIncrement​(boolean isAutoIncrement)
        Sets whether or not the column has an auto incremented value
        Parameters:
        isAutoIncrement - True - auto increment, False - do not auto increment
        Returns:
        this column
      • check

        public Column check​(@NonNull
                            @NonNull SQLElement element)
        Adds a Check constraint on this column.
        Parameters:
        element - the check
        Returns:
        this column
      • check

        public Column check​(String name,
                            @NonNull
                            @NonNull SQLElement element)
        Adds a Check constraint with the given name on this column.
        Parameters:
        name - the name of the constraint
        element - the check
        Returns:
        this column
      • clearConstraints

        public void clearConstraints()
        Clears all constraints on the column.
      • collate

        public Column collate​(String collate)
        Sets the collation used for this column
        Parameters:
        collate - the collation
        Returns:
        this column
      • defaultValue

        public Column defaultValue​(SQLElement defaultValue)
        Sets the default value to be assigned to the column when no value is given on an insert.
        Parameters:
        defaultValue - the default value
        Returns:
        this column
      • getConstraints

        public List<Constraint> getConstraints()
        Gets an unmodifiable view of the constraints on the column.
        Returns:
        the constraints
      • hasConstraintOfType

        public boolean hasConstraintOfType​(@NonNull
                                           @NonNull Class<? extends Constraint> constraintClass)
        Checks if a constraint of the give type is on the column
        Parameters:
        constraintClass - the constraint class
        Returns:
        True if the column has at least one constraint of the given type
      • isRequired

        public boolean isRequired()
        Determines if the column is requires a value to be specified during insertion.
        Returns:
        true if the column requires a value to be specified during insertion, false not required.
      • notNull

        public Column notNull()
        Sets the column to not allow null values.
        Returns:
        this column
      • notNull

        public Column notNull​(ConflictClause conflictClause)
        Sets the column to not allow null values optionally specifying what happens when insertion of a null value is attempted.
        Parameters:
        conflictClause - the ConflictClause defining what happens when insertion of a null value is attempted.
        Returns:
        this column
      • primaryKey

        public Column primaryKey()
        Sets this column as the primary key of the table.
        Returns:
        this column
      • unique

        public Column unique()
        Sets the column to have a uniqueness constraint
        Returns:
        this column
      • unique

        public Column unique​(String name)
        Sets the column to have a uniqueness constraint
        Parameters:
        name - the name of the constraint
        Returns:
        this column
      • unique

        public Column unique​(ConflictClause conflictClause)
        Sets the column to have a uniqueness constraint optionally specifying what happens when insertion of a duplicate value is attempted.
        Parameters:
        conflictClause - the ConflictClause defining what happens when insertion of a duplicate value is attempted.
        Returns:
        this column
      • unique

        public Column unique​(@NonNull
                             @NonNull String name,
                             ConflictClause conflictClause)
        Sets the column to have a uniqueness constraint optionally specifying what happens when insertion of a duplicate value is attempted.
        Parameters:
        name - the name of the constraint
        conflictClause - the ConflictClause defining what happens when insertion of a duplicate value is attempted.
        Returns:
        this column