Class DbEntity.Builder

    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • name

        public DbEntity.Builder name​(String name)
        Sets the entity name.
        Parameters:
        name - The entity name.
        Returns:
        This builder.
      • addColumn

        public DbEntity.Builder addColumn​(DbColumn dbColumn)
        Adds a column to the entity.
        Parameters:
        dbColumn - The column to add.
        Returns:
        This builder.
      • removeColumn

        public DbEntity.Builder removeColumn​(String name)
        Removes the column with the given name.
        Parameters:
        name - The column name to remove.
        Returns:
        This builder.
      • addColumn

        public DbEntity.Builder addColumn​(Collection<DbColumn> dbColumn)
        Adds the columns to the entity.
        Parameters:
        dbColumn - The columns to add.
        Returns:
        This builder.
      • addColumn

        public DbEntity.Builder addColumn​(String name,
                                          DbColumnType type,
                                          DbColumnConstraint... constraints)
        Adds a column to the entity.
        Parameters:
        name - The entity name.
        type - The entity type.
        constraints - The list of constraints.
        Returns:
        This builder.
      • addColumn

        public DbEntity.Builder addColumn​(String name,
                                          DbColumnType type,
                                          Integer size,
                                          DbColumnConstraint... constraints)
        Adds a column to the entity.
        Parameters:
        name - The entity name.
        type - The entity type.
        size - The type size.
        constraints - The list of constraints.
        Returns:
        This builder.
      • addColumn

        public DbEntity.Builder addColumn​(String name,
                                          DbColumnType type,
                                          boolean autoInc,
                                          DbColumnConstraint... constraints)
        Adds a column to the entity.
        Parameters:
        name - The entity name.
        type - The entity type.
        autoInc - true if the column is to autoincrement, false otherwise.
        constraints - The list of constraints.
        Returns:
        This builder.
      • addColumn

        public DbEntity.Builder addColumn​(String name,
                                          DbColumnType type,
                                          K defaultValue,
                                          DbColumnConstraint... constraints)
        Adds a column to the entity.
        Parameters:
        name - The entity name.
        type - The entity type.
        defaultValue - The defaultValue for the column.
        constraints - The list of constraints.
        Returns:
        This builder.
      • addColumn

        public DbEntity.Builder addColumn​(String name,
                                          DbColumnType type,
                                          Integer size,
                                          boolean autoInc,
                                          DbColumnConstraint... constraints)
        Adds a column to the entity.
        Parameters:
        name - The entity name.
        type - The entity type.
        size - The type size.
        autoInc - True if the column is to autoincrement, false otherwise.
        constraints - The list of constraints.
        Returns:
        This builder.
      • pkFields

        public DbEntity.Builder pkFields​(String... pkFields)
        Sets the PK fields.
        Parameters:
        pkFields - The PK fields.
        Returns:
        This builder.
      • addIndex

        public DbEntity.Builder addIndex​(DbIndex index)
        Adds an index.
        Parameters:
        index - The index.
        Returns:
        This builder.
      • addIndex

        public DbEntity.Builder addIndex​(boolean unique,
                                         String... columns)
        Adds an index.
        Parameters:
        unique - true if the index is unique, false otherwise.
        columns - The columns that are part of the index.
        Returns:
        This builder.
      • addIndex

        public DbEntity.Builder addIndex​(String... columns)
        Adds an index.
        Parameters:
        columns - The columns that are part of the index.
        Returns:
        This builder.
      • addIndex

        public DbEntity.Builder addIndex​(Collection<String> columns)
        Adds an index.
        Parameters:
        columns - The columns that are part of the index.
        Returns:
        This builder.
      • addFk

        public DbEntity.Builder addFk​(DbFk... fks)
        Adds the FKs.
        Parameters:
        fks - The list of FKs.
        Returns:
        This builder.
      • addFk

        public DbEntity.Builder addFk​(DbFk.Builder... fks)
        Adds the FKs.
        Parameters:
        fks - The list FKs builders..
        Returns:
        This builder.
      • clearFks

        public DbEntity.Builder clearFks()
        Clears all the FKs in this builder.
        Returns:
        This builder.
      • build

        public DbEntity build()
        Description copied from interface: Builder
        Builds the final immutable instance.
        Specified by:
        build in interface Builder<DbEntity>
        Returns:
        The final immutable instance.