T
- enum typepublic final class EnumCodec<T extends Enum<T>> extends Object implements Codec<T>
enumerated
types to Java Enum
values.
This codec uses Enum.name()
to map Postgres enum values as these are represented as string values.
Note that enum values are case-sensitive.
Modifier and Type | Class and Description |
---|---|
static class |
EnumCodec.Builder
Builder for
CodecRegistrar to register EnumCodec for one or more enum type mappings. |
Constructor and Description |
---|
EnumCodec(io.netty.buffer.ByteBufAllocator byteBufAllocator,
Class<T> type,
int oid) |
Modifier and Type | Method and Description |
---|---|
static EnumCodec.Builder |
builder()
Create a new
EnumCodec.Builder to build a CodecRegistrar to dynamically register Postgres enum types to Enum values. |
boolean |
canDecode(int dataType,
io.r2dbc.postgresql.message.Format format,
Class<?> type)
|
boolean |
canEncode(Object value)
Determine whether this
Codec is capable of encoding the value . |
boolean |
canEncodeNull(Class<?> type)
|
T |
decode(io.netty.buffer.ByteBuf buffer,
int dataType,
io.r2dbc.postgresql.message.Format format,
Class<? extends T> type)
Decode the
buffer and return it as the requested type . |
io.r2dbc.postgresql.client.Parameter |
encode(Object value)
Encode the
value to be used as RPC parameter. |
io.r2dbc.postgresql.client.Parameter |
encodeNull()
Encode a
null value. |
Class<?> |
type()
Returns the Java
type of this codec. |
public boolean canDecode(int dataType, io.r2dbc.postgresql.message.Format format, Class<?> type)
Codec
public boolean canEncode(Object value)
Codec
Codec
is capable of encoding the value
.public boolean canEncodeNull(Class<?> type)
Codec
canEncodeNull
in interface Codec<T extends Enum<T>>
type
- the desired value typetrue
if this Codec
is able to encode null
values for the given Class
type.Codec.encodeNull()
public T decode(@Nullable io.netty.buffer.ByteBuf buffer, int dataType, io.r2dbc.postgresql.message.Format format, Class<? extends T> type)
Codec
buffer
and return it as the requested type
.public io.r2dbc.postgresql.client.Parameter encode(Object value)
Codec
value
to be used as RPC parameter.public io.r2dbc.postgresql.client.Parameter encodeNull()
Codec
null
value.encodeNull
in interface Codec<T extends Enum<T>>
null
valuepublic Class<?> type()
Codec
type
of this codec.public static EnumCodec.Builder builder()
EnumCodec.Builder
to build a CodecRegistrar
to dynamically register Postgres enum
types to Enum
values.Copyright © 2020. All rights reserved.