Class DbEntity.Builder
- java.lang.Object
-
- com.feedzai.commons.sql.abstraction.ddl.DbEntity.Builder
-
- All Implemented Interfaces:
Builder<DbEntity>,Serializable
- Enclosing class:
- DbEntity
public static class DbEntity.Builder extends Object implements Builder<DbEntity>, Serializable
Builder to create immutableDbEntityobjects.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DbEntity.BuilderaddColumn(DbColumn dbColumn)Adds a column to the entity.DbEntity.BuilderaddColumn(String name, DbColumnType type, boolean autoInc, DbColumnConstraint... constraints)Adds a column to the entity.DbEntity.BuilderaddColumn(String name, DbColumnType type, DbColumnConstraint... constraints)Adds a column to the entity.DbEntity.BuilderaddColumn(String name, DbColumnType type, K defaultValue, DbColumnConstraint... constraints)Adds a column to the entity.DbEntity.BuilderaddColumn(String name, DbColumnType type, Integer size, boolean autoInc, DbColumnConstraint... constraints)Adds a column to the entity.DbEntity.BuilderaddColumn(String name, DbColumnType type, Integer size, DbColumnConstraint... constraints)Adds a column to the entity.DbEntity.BuilderaddColumn(Collection<DbColumn> dbColumn)Adds the columns to the entity.DbEntity.BuilderaddFk(DbFk.Builder... fks)Adds the FKs.DbEntity.BuilderaddFk(DbFk... fks)Adds the FKs.DbEntity.BuilderaddFk(Collection<DbFk> fks)Adds the FKs.DbEntity.BuilderaddFks(Collection<DbFk> fks)Adds the FKs.DbEntity.BuilderaddIndex(boolean unique, String... columns)Adds an index.DbEntity.BuilderaddIndex(DbIndex index)Adds an index.DbEntity.BuilderaddIndex(String... columns)Adds an index.DbEntity.BuilderaddIndex(Collection<String> columns)Adds an index.DbEntity.BuilderaddIndexes(Collection<DbIndex> indexes)Adds an index.DbEntitybuild()Builds the final immutable instance.DbEntity.BuilderclearFks()Clears all the FKs in this builder.DbEntity.Buildername(String name)Sets the entity name.DbEntity.BuilderpkFields(String... pkFields)Sets the PK fields.DbEntity.BuilderpkFields(Collection<String> pkFields)Sets the PK fields.DbEntity.BuilderremoveColumn(String name)Removes the column with the given name.
-
-
-
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-trueif the column is to autoincrement,falseotherwise.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.
-
pkFields
public DbEntity.Builder pkFields(Collection<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.
-
addIndexes
public DbEntity.Builder addIndexes(Collection<DbIndex> indexes)
Adds an index.- Parameters:
indexes- The index.- Returns:
- This builder.
-
addIndex
public DbEntity.Builder addIndex(boolean unique, String... columns)
Adds an index.- Parameters:
unique-trueif the index is unique,falseotherwise.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.
-
addFk
public DbEntity.Builder addFk(Collection<DbFk> fks)
Adds the FKs.- Parameters:
fks- The list of FKs.- Returns:
- This builder.
-
clearFks
public DbEntity.Builder clearFks()
Clears all the FKs in this builder.- Returns:
- This builder.
-
addFks
public DbEntity.Builder addFks(Collection<DbFk> fks)
Adds the FKs.- Parameters:
fks- The list of FKs.- Returns:
- This object.
-
-