Class Table.Builder

    • Method Detail

      • setVersion

        public Table.Builder setVersion​(int v)
        Set the version
        Parameters:
        v -
        Returns:
      • setTablespace

        public Table.Builder setTablespace​(Tablespace ts)
        Setter for the tablespace
        Parameters:
        ts -
        Returns:
      • setCreate

        public Table.Builder setCreate​(boolean flag)
        Setter for the create flag
        Parameters:
        flag - true is the default for new tables; set to false to avoid creating this table
        Returns:
      • setDistributionType

        public Table.Builder setDistributionType​(DistributionType dt)
        Setter for the distributionType
        Parameters:
        cn -
        Returns:
      • setDistributionColumnName

        public Table.Builder setDistributionColumnName​(java.lang.String columnName)
        Setter for the distributionColumnName value
        Parameters:
        columnName -
        Returns:
      • addIntColumn

        public Table.Builder addIntColumn​(java.lang.String columnName,
                                          boolean nullable)
      • addSmallIntColumn

        public Table.Builder addSmallIntColumn​(java.lang.String columnName,
                                               java.lang.Integer defaultValue,
                                               boolean nullable)
      • addSmallIntBooleanColumn

        public Table.Builder addSmallIntBooleanColumn​(java.lang.String columnName,
                                                      java.lang.Integer defaultValue,
                                                      boolean nullable)
        Variant used by JavaBatch which is BOOLEAN in PostgreSQL but SMALLINT elsewhere
        Parameters:
        columnName -
        defaultValue -
        nullable -
        Returns:
      • addBigIntColumn

        public Table.Builder addBigIntColumn​(java.lang.String columnName,
                                             boolean nullable)
      • addBigIntColumn

        public Table.Builder addBigIntColumn​(java.lang.String columnName,
                                             boolean nullable,
                                             java.lang.String defaultValue)
      • addDoubleColumn

        public Table.Builder addDoubleColumn​(java.lang.String columnName,
                                             boolean nullable)
      • addTimestampColumn

        public Table.Builder addTimestampColumn​(java.lang.String columnName,
                                                boolean nullable)
      • addTimestampColumn

        public Table.Builder addTimestampColumn​(java.lang.String columnName,
                                                boolean nullable,
                                                java.lang.String defaultValue)
      • addTimestampColumn

        public Table.Builder addTimestampColumn​(java.lang.String columnName,
                                                int numberOfFractionalSecondDigits,
                                                boolean nullable)
      • addVarcharColumn

        public Table.Builder addVarcharColumn​(java.lang.String columnName,
                                              int size,
                                              boolean nullable)
      • addVarbinaryColumn

        public Table.Builder addVarbinaryColumn​(java.lang.String columnName,
                                                int size,
                                                boolean nullable)
        Add a VARBINARY(nn) column
        Parameters:
        columnName -
        size -
        nullable -
        Returns:
      • addCharColumn

        public Table.Builder addCharColumn​(java.lang.String columnName,
                                           int size,
                                           boolean nullable)
        Add char (fixed-width) column
        Parameters:
        columnName -
        size -
        nullable -
        Returns:
      • addCharColumn

        public Table.Builder addCharColumn​(java.lang.String columnName,
                                           int size,
                                           boolean nullable,
                                           java.lang.String defaultValue)
        Add char (fixed-width) column with a default value specified
        Parameters:
        columnName -
        size -
        nullable -
        defaultValue -
        Returns:
      • addBlobColumn

        public Table.Builder addBlobColumn​(java.lang.String columnName,
                                           long size,
                                           int inlineSize,
                                           boolean nullable)
      • addClobColumn

        public Table.Builder addClobColumn​(java.lang.String columnName,
                                           boolean nullable,
                                           java.lang.String defaultVal)
        Parameters:
        columnName -
        nullable -
        defaultVal - this value is auto-quoted; do not pass the single-quote (') within the string value
        Returns:
      • setIdentityColumn

        public Table.Builder setIdentityColumn​(java.lang.String columnName,
                                               Generated generated)
        Set one of the columns to be the identity column for the table
        Parameters:
        constraintName -
        columns -
        Returns:
      • addPrimaryKey

        public Table.Builder addPrimaryKey​(java.lang.String constraintName,
                                           java.lang.String... columns)
        Add a primary key constraint to the table
        Parameters:
        constraintName -
        columns -
        Returns:
      • addIndex

        public Table.Builder addIndex​(java.lang.String indexName,
                                      java.lang.String... columns)
        Add an index to the table using the list of column names
        Parameters:
        indexName -
        columns -
        Returns:
      • addUniqueIndex

        public Table.Builder addUniqueIndex​(java.lang.String indexName,
                                            java.lang.String... columns)
        Add a unique index to the table using the list of column names
        Parameters:
        indexName -
        columns -
        Returns:
      • addUniqueIndex

        public Table.Builder addUniqueIndex​(java.lang.String indexName,
                                            java.util.Collection<java.lang.String> indexColumns,
                                            java.util.Collection<java.lang.String> includeColumns)
        Add a unique index with include columns
        Parameters:
        indexName -
        indexColumns -
        includeColumns -
        Returns:
      • addUniqueConstraint

        public Table.Builder addUniqueConstraint​(java.lang.String constraintName,
                                                 java.lang.String... columnName)
        Add a unique constraint to the table/column
        Parameters:
        constraintName -
        columnName - - at least one column
        Returns:
      • addCheckConstraint

        public Table.Builder addCheckConstraint​(java.lang.String constraintName,
                                                java.lang.String constraintExpression)
      • addForeignKeyConstraint

        public Table.Builder addForeignKeyConstraint​(java.lang.String constraintName,
                                                     java.lang.String targetSchema,
                                                     java.lang.String targetTable,
                                                     java.lang.String... columns)
        Add a foreign key constraint pointing to the target table (with enforcement). The list of columns is expected to match the primary key definition on the target.
        Parameters:
        constraintName -
        targetSchema -
        targetTable -
        columns -
        Returns:
      • addForeignKeyConstraint

        public Table.Builder addForeignKeyConstraint​(java.lang.String constraintName,
                                                     boolean enforced,
                                                     java.lang.String targetSchema,
                                                     java.lang.String targetTable,
                                                     java.lang.String... columns)
        Add a foreign key constraint pointing to the target table. The list of columns is expected to match the primary key definition on the target
        Parameters:
        constraintName -
        enforced -
        targetSchema -
        targetTable -
        columns -
        Returns:
      • addForeignKeyConstraintSelf

        public Table.Builder addForeignKeyConstraintSelf​(java.lang.String constraintName,
                                                         java.lang.String targetSchema,
                                                         java.lang.String targetTable,
                                                         java.lang.String targetColumnName,
                                                         java.lang.String... columns)
        Adds a foreign key constraint relationship on itself. This is intentionally created as a separate method, so there are no mistakes.
        Parameters:
        constraintName -
        targetSchema -
        targetTable -
        targetColumnName -
        columns -
        Returns:
      • addForeignKeyConstraintAltTarget

        public Table.Builder addForeignKeyConstraintAltTarget​(java.lang.String constraintName,
                                                              java.lang.String targetSchema,
                                                              java.lang.String targetTable,
                                                              java.lang.String targetColumnName,
                                                              java.lang.String... columns)
        Adds a foreign key constraint relationship on itself. This is intentionally created as a separate method, so there are no mistakes.
        Parameters:
        constraintName -
        targetSchema -
        targetTable -
        targetColumnName -
        columns -
        Returns:
      • checkColumns

        protected void checkColumns​(java.lang.String[] columns)
        Check each of the columns in the given array are valid column names
        Parameters:
        columns -
      • checkColumns

        protected void checkColumns​(java.util.Collection<java.lang.String> columns)
        Check each of the columns in the given array are valid column names
        Parameters:
        columns -
      • build

        public Table build​(IDataModel dataModel)
        Build the immutable table object based on the current configuration
        Parameters:
        dataModel -
        Returns:
      • buildColumns

        protected java.util.List<ColumnBase> buildColumns()
        Create the columns for the table based on the definitions that have been added
        Returns:
      • addTag

        public Table.Builder addTag​(java.lang.String tagName,
                                    java.lang.String tagValue)
        Parameters:
        tagName -
        tagValue -
        Returns:
      • addPrivileges

        public Table.Builder addPrivileges​(java.util.Collection<GroupPrivilege> gps)
        Add the collection of group privileges to this table
        Parameters:
        gps -
        Returns:
      • addWiths

        public Table.Builder addWiths​(java.util.List<With> withs)
        adds with parameters (key-values) to the table definition.
        Parameters:
        withs -