public abstract class AbstractColumnMapping<R> extends java.lang.Object implements ColumnMapping<R>
Since entity columns are proto-based and have a limited amount of possible types, this class allows descendants to override concrete type mapping rules in a convenient way.
Some of the types are expected to be mapped in a way so they support the ordering comparison
operators ("greater than", "less than or equals", etc.). For details, see
Filters
.
Constructor and Description |
---|
AbstractColumnMapping() |
Modifier and Type | Method and Description |
---|---|
<T> ColumnTypeMapping<T,? extends R> |
of(java.lang.Class<T> type)
Obtains the mapping rules for the given type.
|
protected abstract ColumnTypeMapping<java.lang.Boolean,? extends R> |
ofBoolean()
Returns the mapping rules of
Boolean columns. |
protected abstract ColumnTypeMapping<com.google.protobuf.ByteString,? extends R> |
ofByteString()
Returns the mapping rules of
ByteString columns. |
protected abstract ColumnTypeMapping<java.lang.Double,? extends R> |
ofDouble()
Returns the mapping rules of
Double columns. |
protected abstract ColumnTypeMapping<java.lang.Enum<?>,? extends R> |
ofEnum()
Returns the mapping rules of
Enum columns. |
protected abstract ColumnTypeMapping<java.lang.Float,? extends R> |
ofFloat()
Returns the mapping rules of
Float columns. |
protected abstract ColumnTypeMapping<java.lang.Integer,? extends R> |
ofInteger()
Returns the mapping rules of
Integer columns. |
protected abstract ColumnTypeMapping<java.lang.Long,? extends R> |
ofLong()
Returns the mapping rules of
Long columns. |
protected abstract ColumnTypeMapping<com.google.protobuf.Message,? extends R> |
ofMessage()
Returns the mapping rules of
Message columns. |
protected abstract ColumnTypeMapping<java.lang.String,? extends R> |
ofString()
Returns the mapping rules of
String columns. |
protected void |
setupCustomMapping(com.google.common.collect.ImmutableMap.Builder<java.lang.Class<?>,ColumnTypeMapping<?,? extends R>> builder)
Allows to specify custom mapping rules.
|
protected java.lang.IllegalArgumentException |
unsupportedType(java.lang.Class<?> aClass)
Throws an exception about an unsupported column type.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
ofNull
public <T> ColumnTypeMapping<T,? extends R> of(java.lang.Class<T> type)
ColumnMapping
of
in interface ColumnMapping<R>
T
- the column typeprotected void setupCustomMapping(com.google.common.collect.ImmutableMap.Builder<java.lang.Class<?>,ColumnTypeMapping<?,? extends R>> builder)
If some message types are needed to be stored differently to the generic messages, the rules for their storage can be specified using this method.
The common examples of such messages are Timestamp
and Version
.
The custom mapping can also be specified for marker interfaces of messages like
EventMessage
.
protected abstract ColumnTypeMapping<java.lang.String,? extends R> ofString()
String
columns.protected abstract ColumnTypeMapping<java.lang.Integer,? extends R> ofInteger()
Integer
columns.protected abstract ColumnTypeMapping<java.lang.Long,? extends R> ofLong()
Long
columns.protected abstract ColumnTypeMapping<java.lang.Float,? extends R> ofFloat()
Float
columns.protected abstract ColumnTypeMapping<java.lang.Double,? extends R> ofDouble()
Double
columns.protected abstract ColumnTypeMapping<java.lang.Boolean,? extends R> ofBoolean()
Boolean
columns.protected abstract ColumnTypeMapping<com.google.protobuf.ByteString,? extends R> ofByteString()
ByteString
columns.protected abstract ColumnTypeMapping<java.lang.Enum<?>,? extends R> ofEnum()
Enum
columns.protected abstract ColumnTypeMapping<com.google.protobuf.Message,? extends R> ofMessage()
Message
columns.protected java.lang.IllegalArgumentException unsupportedType(java.lang.Class<?> aClass)