I
- the ID type@Internal
public abstract class IdColumn<I>
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
TableColumn |
column() |
java.lang.String |
columnName() |
abstract java.lang.Class<I> |
javaType()
Retrieves the Java class of the ID before
normalization.
|
abstract java.lang.Object |
normalize(I id)
Normalizes the identifier before setting it to a
Parameter . |
java.util.Collection<java.lang.Object> |
normalize(java.lang.Iterable<I> ids)
Normalizes the specified IDs.
|
static <I> IdColumn<I> |
of(TableColumn column)
Wraps a given ID
column of a primitive type. |
static <I extends com.google.protobuf.Message> |
of(TableColumn column,
java.lang.Class<I> messageClass)
Wraps a given ID
column of Message type. |
static <I> IdColumn<I> |
ofEntityClass(TableColumn column,
java.lang.Class<? extends io.spine.server.entity.Entity<I,?>> entityClass)
Wraps a given
Entity ID column. |
void |
setId(java.lang.String idName,
I id,
Parameters.Builder parameters)
Sets an ID parameter to the given value.
|
abstract Type |
sqlType()
Returns the
Type of the column with which this helper instance works. |
public static <I> IdColumn<I> of(TableColumn column)
column
of a primitive type.
The column should have a valid SQL type.
This also implies that actual ID values will be primitive and matching to the column SQL type.
public static <I extends com.google.protobuf.Message> IdColumn<I> of(TableColumn column, java.lang.Class<I> messageClass)
column
of Message
type.
The column should have an SQL type set to null
.
public static <I> IdColumn<I> ofEntityClass(TableColumn column, java.lang.Class<? extends io.spine.server.entity.Entity<I,?>> entityClass)
Entity
ID column.
The column should have an SQL type set to null
.
The column type is calculated at runtime according to the generic parameters of the
Entity
class.
I
- the type of Entity
IDsentityClass
- a class of an Entity
or an Aggregate
public abstract Type sqlType()
Type
of the column with which this helper instance works.public abstract java.lang.Class<I> javaType()
public abstract java.lang.Object normalize(I id)
Parameter
.
The method may perform a conversion of the ID to a type, which is more suitable
for storing. E.g. it may be useful to store a Protobuf Message
in a JSON representation as a String
.
If an ID type is a simple type as String
, Integer
, etc
the method may return the same value.
id
- the identifier to normalizepublic java.util.Collection<java.lang.Object> normalize(java.lang.Iterable<I> ids)
ids
- the IDs to normalizepublic java.lang.String columnName()
public TableColumn column()
public void setId(java.lang.String idName, I id, Parameters.Builder parameters)
idName
- the name of the IDid
- the ID value to setparameters
- the parameters to set the ID