Package guru.mikelue.jdut.datagrain
Class SchemaTable
- java.lang.Object
-
- guru.mikelue.jdut.datagrain.SchemaTable
-
public class SchemaTable extends Object
The schema of table.
Building of data
While you are building data for testing, this object defines necessary to declare the data of a table.
The name of table and keys(for deletion) is used by operators of data grain.Validation of data
After the schema information is fetched from real database, this object contains the real schema defined in database. And, the auto-inspected keys if there is no one while building data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
SchemaTable.Builder
This object is used withConsumer
bybuild(java.util.function.Consumer<guru.mikelue.jdut.datagrain.SchemaTable.Builder>)
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SchemaTable
build(Consumer<SchemaTable.Builder> builderConsumer)
Builds a table schema byConsumer
.protected SchemaTable
clone()
Safe clone for the fields of this object.boolean
equals(Object obj)
Compares the name of table, columns, keys, and indexed columns.Optional<String>
getCatalog()
Gets optional value of schema.SchemaColumn
getColumn(int columnIndex)
Gets the column definition by column index.SchemaColumn
getColumn(String columnName)
Gets the column definition by name.List<SchemaColumn>
getColumns()
Gets the columns(sorted by added sequence).String
getFullTableName()
Gets name of table with catalog and schema and keys.
Use"<null>"
if the value is not setList<String>
getKeys()
Gets keys of table.MetaDataWorker
getMetaDataWorker()
Gets the worker of meta-data.String
getName()
Gets name of table.int
getNumberOfColumns()
Gets number of columns.String
getQuotedFullName()
Gets quoted string of full name(may be include schema) of table.Optional<String>
getSchema()
Gets optional value of schema.boolean
hasColumn(String columnName)
Whether or not has a column by name.int
hashCode()
Hashes the name of table, columns, keys, and indexed columns.String
quoteIdentifier(String identifier)
UseDatabaseMetaData.getIdentifierQuoteString()
to quote identifier.String
toString()
String
treatIdentifier(String identifier)
Converts the case of identifier by meta-data of database.
-
-
-
Method Detail
-
build
public static SchemaTable build(Consumer<SchemaTable.Builder> builderConsumer)
Builds a table schema byConsumer
.- Parameters:
builderConsumer
- The building code for table schema- Returns:
- The result schema of table
-
getMetaDataWorker
public MetaDataWorker getMetaDataWorker()
Gets the worker of meta-data.
-
getName
public String getName()
Gets name of table.- Returns:
- The name of table
-
getQuotedFullName
public String getQuotedFullName()
Gets quoted string of full name(may be include schema) of table. If theSchemaTable.Builder.metaDataWorker(MetaDataWorker)
is not set, the value returned by this method would be as same asgetName()
.- Returns:
- The quoted name of table
-
getNumberOfColumns
public int getNumberOfColumns()
Gets number of columns.- Returns:
- The number of columns
-
getColumns
public List<SchemaColumn> getColumns()
Gets the columns(sorted by added sequence).- Returns:
- The columns
-
hasColumn
public boolean hasColumn(String columnName)
Whether or not has a column by name.- Parameters:
columnName
- The name of column- Returns:
- true if the column is existing
-
getColumn
public SchemaColumn getColumn(String columnName)
Gets the column definition by name.- Parameters:
columnName
- The name of column- Returns:
- The column definition
- Throws:
IllegalArgumentException
- If the name of column cannot be found for definition
-
getColumn
public SchemaColumn getColumn(int columnIndex)
Gets the column definition by column index.- Parameters:
columnIndex
- The index of column- Returns:
- The column definition
- Throws:
IllegalArgumentException
- If the name of column cannot be found for definition
-
treatIdentifier
public String treatIdentifier(String identifier)
Converts the case of identifier by meta-data of database.- Parameters:
identifier
- The identifier to be processed- Returns:
- The processed identifier
-
quoteIdentifier
public String quoteIdentifier(String identifier)
UseDatabaseMetaData.getIdentifierQuoteString()
to quote identifier.- Parameters:
identifier
- The identifier to be quoted- Returns:
- The quoted identifier
-
getFullTableName
public String getFullTableName()
Gets name of table with catalog and schema and keys.
Use"<null>"
if the value is not set- Returns:
- The string can be used in collection
-
clone
protected SchemaTable clone()
Safe clone for the fields of this object.
-
equals
public boolean equals(Object obj)
Compares the name of table, columns, keys, and indexed columns.
-
hashCode
public int hashCode()
Hashes the name of table, columns, keys, and indexed columns.
-
-