CHILD
- The child entity typePARENT
- The parent entity typeCHILDBUILDER
- The class used to construct new CHILD
instancesPARENTBUILDER
- The class used to construct new PARENT
instancespublic class ParentColumnImpl<CHILD,PARENT,CHILDBUILDER,PARENTBUILDER> extends Object implements ParentColumn<CHILD,PARENT,CHILDBUILDER,PARENTBUILDER>
Most users of hrorm will have no need to directly use this.
Constructor and Description |
---|
ParentColumnImpl(String name,
String prefix,
Function<CHILD,PARENT> getter,
BiConsumer<CHILDBUILDER,PARENT> setter) |
ParentColumnImpl(String name,
String prefix,
Function<CHILD,PARENT> getter,
BiConsumer<CHILDBUILDER,PARENT> setter,
PrimaryKey<PARENT,PARENTBUILDER> parentPrimaryKey,
boolean nullable) |
Modifier and Type | Method and Description |
---|---|
String |
getName()
The name of the database column this instance represents.
|
Long |
getParentId(CHILD child) |
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(CHILDBUILDER item,
ResultSet resultSet)
Populates the object with the data read from the database.
|
void |
setParentPrimaryKey(PrimaryKey<PARENT,PARENTBUILDER> parentPrimaryKey) |
void |
setSqlTypeName(String sqlTypeName) |
BiConsumer<CHILDBUILDER,PARENT> |
setter() |
void |
setValue(CHILD 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<CHILD,CHILDBUILDER> |
withPrefix(String prefix,
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 ParentColumnImpl(String name, String prefix, Function<CHILD,PARENT> getter, BiConsumer<CHILDBUILDER,PARENT> setter)
public ParentColumnImpl(String name, String prefix, Function<CHILD,PARENT> getter, BiConsumer<CHILDBUILDER,PARENT> setter, PrimaryKey<PARENT,PARENTBUILDER> parentPrimaryKey, boolean nullable)
public String getName()
Column
getName
in interface Column<CHILD,CHILDBUILDER>
public String getPrefix()
Column
getPrefix
in interface Column<CHILD,CHILDBUILDER>
public PopulateResult populate(CHILDBUILDER item, ResultSet resultSet)
Column
populate
in interface Column<CHILD,CHILDBUILDER>
item
- The object being populatedresultSet
- The result said being readpublic void setValue(CHILD item, int index, PreparedStatement preparedStatement)
Column
setValue
in interface Column<CHILD,CHILDBUILDER>
item
- The object to read the data from.index
- Where in the prepared statement to set the read valuepreparedStatement
- The statement being populatedpublic Column<CHILD,CHILDBUILDER> withPrefix(String prefix, Prefixer prefixer)
Column
withPrefix
in interface Column<CHILD,CHILDBUILDER>
prefix
- The new prefixprefixer
- The source for new prefixespublic void notNull()
Column
notNull
in interface Column<CHILD,CHILDBUILDER>
public BiConsumer<CHILDBUILDER,PARENT> setter()
setter
in interface ParentColumn<CHILD,PARENT,CHILDBUILDER,PARENTBUILDER>
public void setParentPrimaryKey(PrimaryKey<PARENT,PARENTBUILDER> parentPrimaryKey)
setParentPrimaryKey
in interface ParentColumn<CHILD,PARENT,CHILDBUILDER,PARENTBUILDER>
public Set<Integer> supportedTypes()
Column
java.sql.Types
that this column should support.supportedTypes
in interface Column<CHILD,CHILDBUILDER>
public Long getParentId(CHILD child)
getParentId
in interface ParentColumn<CHILD,PARENT,CHILDBUILDER,PARENTBUILDER>
public boolean isNullable()
Column
isNullable
in interface Column<CHILD,CHILDBUILDER>
public String getSqlTypeName()
Column
String
,
"decimal" for BigDecimal
.getSqlTypeName
in interface Column<CHILD,CHILDBUILDER>
public void setSqlTypeName(String sqlTypeName)
setSqlTypeName
in interface Column<CHILD,CHILDBUILDER>
Copyright © 2019. All rights reserved.