Package net.morimekta.providence.jdbi.v3
Class ProvidenceJdbi
- java.lang.Object
-
- net.morimekta.providence.jdbi.v3.ProvidenceJdbi
-
public class ProvidenceJdbi extends java.lang.Object
Utility class and helper to make mappers and argument helpers for JDBI queries and updates.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ProvidenceJdbi.MappedField<M extends net.morimekta.providence.PMessage<M>>
-
Constructor Summary
Constructors Constructor Description ProvidenceJdbi()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <M extends net.morimekta.providence.PMessage<M>>
ProvidenceJdbi.MappedField<M>columnsFromAllFields()
With all column with default types.static <M extends net.morimekta.providence.PMessage<M>>
MessageNamedArgumentFinder<M>forMessage(java.lang.String prefix, net.morimekta.providence.PMessageOrBuilder<M> message, FieldType<M>... fieldTypes)
Get named argument finder for message.static <M extends net.morimekta.providence.PMessage<M>>
MessageNamedArgumentFinder<M>forMessage(net.morimekta.providence.PMessageOrBuilder<M> message, FieldType<M>... fieldTypes)
Get named argument finder for message.static <M extends net.morimekta.providence.PMessage<M>>
MessageFieldArgument<M>toField(net.morimekta.providence.PMessageOrBuilder<M> message, net.morimekta.providence.descriptor.PField<M> field)
Bind to the given field for the message.static <M extends net.morimekta.providence.PMessage<M>>
MessageFieldArgument<M>toField(net.morimekta.providence.PMessageOrBuilder<M> message, net.morimekta.providence.descriptor.PField<M> field, int type)
Bind to the given field for the message.static <M extends net.morimekta.providence.PMessage<M>>
MessageRowMapper<M>toMessage(java.lang.String tableName, net.morimekta.providence.descriptor.PMessageDescriptor<M> descriptor, ProvidenceJdbi.MappedField<M>... fieldMapping)
Bind to message using row mapper.static <M extends net.morimekta.providence.PMessage<M>>
MessageRowMapper<M>toMessage(net.morimekta.providence.descriptor.PMessageDescriptor<M> descriptor, ProvidenceJdbi.MappedField<M>... fieldMapping)
Bind to message using row mapper.static <M extends net.morimekta.providence.PMessage<M>>
ProvidenceJdbi.MappedField<M>withColumn(java.lang.String name, net.morimekta.providence.descriptor.PField<M> field)
With column mapped to field.static <M extends net.morimekta.providence.PMessage<M>>
ProvidenceJdbi.MappedField<M>withColumn(net.morimekta.providence.descriptor.PField<M> field)
With column mapped to field using the field name.static <M extends net.morimekta.providence.PMessage<M>>
FieldType<M>withType(net.morimekta.providence.descriptor.PField<M> field, int type)
With field mapped to SQL type.
-
-
-
Method Detail
-
toField
public static <M extends net.morimekta.providence.PMessage<M>> MessageFieldArgument<M> toField(net.morimekta.providence.PMessageOrBuilder<M> message, net.morimekta.providence.descriptor.PField<M> field)
Bind to the given field for the message.- Type Parameters:
M
- The message type.- Parameters:
message
- The message tp bind value from.field
- The field to bind to.- Returns:
- The message field argument.
-
toField
public static <M extends net.morimekta.providence.PMessage<M>> MessageFieldArgument<M> toField(net.morimekta.providence.PMessageOrBuilder<M> message, net.morimekta.providence.descriptor.PField<M> field, int type)
Bind to the given field for the message.- Type Parameters:
M
- The message type.- Parameters:
message
- The message tp bind value from.field
- The field to bind to.type
- The SQL type.- Returns:
- The message field argument.
-
columnsFromAllFields
public static <M extends net.morimekta.providence.PMessage<M>> ProvidenceJdbi.MappedField<M> columnsFromAllFields()
With all column with default types.- Type Parameters:
M
- The message type.- Returns:
- The mapped field.
-
withColumn
public static <M extends net.morimekta.providence.PMessage<M>> ProvidenceJdbi.MappedField<M> withColumn(net.morimekta.providence.descriptor.PField<M> field)
With column mapped to field using the field name.- Type Parameters:
M
- The message type.- Parameters:
field
- Field it is mapped to.- Returns:
- The mapped field.
-
withColumn
public static <M extends net.morimekta.providence.PMessage<M>> ProvidenceJdbi.MappedField<M> withColumn(java.lang.String name, net.morimekta.providence.descriptor.PField<M> field)
With column mapped to field.- Type Parameters:
M
- The message type.- Parameters:
name
- Name of column.field
- Field it is mapped to.- Returns:
- The mapped field.
-
toMessage
@SafeVarargs public static <M extends net.morimekta.providence.PMessage<M>> MessageRowMapper<M> toMessage(@Nonnull net.morimekta.providence.descriptor.PMessageDescriptor<M> descriptor, @Nonnull ProvidenceJdbi.MappedField<M>... fieldMapping)
Bind to message using row mapper.- Type Parameters:
M
- The message type.- Parameters:
descriptor
- The message descriptor.fieldMapping
- Extra field mapping.- Returns:
- The row mapper.
-
toMessage
@SafeVarargs public static <M extends net.morimekta.providence.PMessage<M>> MessageRowMapper<M> toMessage(@Nonnull java.lang.String tableName, @Nonnull net.morimekta.providence.descriptor.PMessageDescriptor<M> descriptor, @Nonnull ProvidenceJdbi.MappedField<M>... fieldMapping)
Bind to message using row mapper.- Type Parameters:
M
- The message type.- Parameters:
tableName
- Table name to restrict field lookup to.descriptor
- The message descriptor.fieldMapping
- Extra field mapping.- Returns:
- The row mapper.
-
withType
public static <M extends net.morimekta.providence.PMessage<M>> FieldType<M> withType(net.morimekta.providence.descriptor.PField<M> field, int type)
With field mapped to SQL type.- Type Parameters:
M
- The message type.- Parameters:
field
- The field to be mapped.type
- The SQL type. SeeTypes
.- Returns:
- The field type mapping.
-
forMessage
@SafeVarargs public static <M extends net.morimekta.providence.PMessage<M>> MessageNamedArgumentFinder<M> forMessage(@Nonnull net.morimekta.providence.PMessageOrBuilder<M> message, @Nonnull FieldType<M>... fieldTypes)
Get named argument finder for message.- Type Parameters:
M
- The message type.- Parameters:
message
- The message to map fields from.fieldTypes
- Field type mappings.- Returns:
- The named argument finder.
-
forMessage
@SafeVarargs public static <M extends net.morimekta.providence.PMessage<M>> MessageNamedArgumentFinder<M> forMessage(@Nonnull java.lang.String prefix, @Nonnull net.morimekta.providence.PMessageOrBuilder<M> message, @Nonnull FieldType<M>... fieldTypes)
Get named argument finder for message.- Type Parameters:
M
- The message type.- Parameters:
prefix
- Name prefix for naming distinction.message
- The message to map fields from.fieldTypes
- Field type mappings.- Returns:
- The named argument finder.
-
-