TYPE
- The type of the data element.ENTITY
- The type of the entity.BUILDER
- The class that is used to build new entity instances.public class ColumnImpl<TYPE,ENTITY,BUILDER> extends Object implements Column<ENTITY,BUILDER>
Column
interface for data elements.
Most users of hrorm will have no need to directly use this.
Constructor and Description |
---|
ColumnImpl(GenericColumn<TYPE> genericColumn,
String prefix,
String name,
Function<ENTITY,MODELTYPE> getter,
BiConsumer<BUILDER,MODELTYPE> setter,
String sqlTypeName,
boolean nullable,
Converter<MODELTYPE,TYPE> converter) |
ColumnImpl(GenericColumn<TYPE> genericColumn,
String prefix,
String name,
Function<ENTITY,TYPE> getter,
BiConsumer<BUILDER,TYPE> setter,
String sqlTypeName,
boolean nullable) |
Modifier and Type | Method and Description |
---|---|
String |
getName()
The name of the database column this instance represents.
|
String |
getPrefix()
The prefix that should be used for this column when generating
SQL.
|
String |
getSqlTypeName()
Returns the name of the column type in SQL, e.g.
|
boolean |
isNullable()
Indicator of whether or not this column is nullable or not.
|
void |
notNull()
Calling this method will enforce a not-null constraint on this column.
|
PopulateResult |
populate(BUILDER builder,
ResultSet resultSet)
Populates the object with the data read from the database.
|
void |
setSqlTypeName(String sqlTypeName) |
void |
setValue(ENTITY item,
int index,
PreparedStatement preparedStatement)
Sets a value onto the prepared statement based on the state of the object passed.
|
Set<Integer> |
supportedTypes()
The members of
java.sql.Types that this column should support. |
Column<ENTITY,BUILDER> |
withPrefix(String newPrefix,
Prefixer prefixer)
Make a new instance of the column, identical to this instance, except with a
new prefix.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isParentColumn, isPrimaryKey
public ColumnImpl(GenericColumn<TYPE> genericColumn, String prefix, String name, Function<ENTITY,TYPE> getter, BiConsumer<BUILDER,TYPE> setter, String sqlTypeName, boolean nullable)
public void setValue(ENTITY item, int index, PreparedStatement preparedStatement) throws SQLException
Column
setValue
in interface Column<ENTITY,BUILDER>
item
- The object to read the data from.index
- Where in the prepared statement to set the read valuepreparedStatement
- The statement being populatedSQLException
- allowed for PreparedStatement
operationspublic PopulateResult populate(BUILDER builder, ResultSet resultSet) throws SQLException
Column
populate
in interface Column<ENTITY,BUILDER>
builder
- The object being populatedresultSet
- The result said being readSQLException
- allowed for ResultSet
operationspublic String getName()
Column
public String getPrefix()
Column
public void notNull()
Column
public boolean isNullable()
Column
isNullable
in interface Column<ENTITY,BUILDER>
public Set<Integer> supportedTypes()
Column
java.sql.Types
that this column should support.supportedTypes
in interface Column<ENTITY,BUILDER>
public String getSqlTypeName()
Column
String
,
"decimal" for BigDecimal
.getSqlTypeName
in interface Column<ENTITY,BUILDER>
public void setSqlTypeName(String sqlTypeName)
setSqlTypeName
in interface Column<ENTITY,BUILDER>
public Column<ENTITY,BUILDER> withPrefix(String newPrefix, Prefixer prefixer)
Column
withPrefix
in interface Column<ENTITY,BUILDER>
newPrefix
- The new prefixprefixer
- The source for new prefixesCopyright © 2019. All rights reserved.