TYPE
- The Java type that this column should be translated to and from.ENTITY
- The entity this column belongs to.BUILDER
- The class that is used to build new entity instances.public abstract class AbstractColumn<TYPE,ENTITY,BUILDER> extends Object implements Column<ENTITY,BUILDER>
Most users of hrorm will have no need to directly use this.
Modifier and Type | Field and Description |
---|---|
protected Function<ENTITY,TYPE> |
getter |
protected boolean |
nullable |
protected BiConsumer<BUILDER,TYPE> |
setter |
Constructor and Description |
---|
AbstractColumn(String name,
String prefix,
Function<ENTITY,TYPE> getter,
BiConsumer<BUILDER,TYPE> setter,
boolean nullable,
String sqlTypeName) |
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.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isParentColumn, isPrimaryKey, supportedTypes, withPrefix
protected final BiConsumer<BUILDER,TYPE> setter
protected boolean nullable
public String getName()
Column
public String getPrefix()
Column
public 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 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 void notNull()
Column
public boolean isNullable()
Column
isNullable
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>
Copyright © 2019. All rights reserved.