Package net.morimekta.providence.jdbi.v3
Class ProvidenceJdbi
- java.lang.Object
-
- net.morimekta.providence.jdbi.v3.ProvidenceJdbi
-
public class ProvidenceJdbi extends java.lang.ObjectUtility 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 classProvidenceJdbi.FieldTypestatic classProvidenceJdbi.MappedField<F extends net.morimekta.providence.descriptor.PField>
-
Constructor Summary
Constructors Constructor Description ProvidenceJdbi()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <F extends net.morimekta.providence.descriptor.PField>
ProvidenceJdbi.MappedField<F>columnsFromAllFields()With all column with default types.static <M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField>
MessageNamedArgumentFinder<M,F>forMessage(java.lang.String prefix, M message, ProvidenceJdbi.FieldType... fieldTypes)Get named argument finder for message.static <M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField>
MessageNamedArgumentFinder<M,F>forMessage(M message, ProvidenceJdbi.FieldType... fieldTypes)Get named argument finder for message.static <M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField>
MessageFieldArgument<M,F>toField(M message, F field)Bind to the given field for the message.static <M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField>
MessageFieldArgument<M,F>toField(M message, F field, int type)Bind to the given field for the message.static <M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField>
MessageRowMapper<M,F>toMessage(java.lang.String tableName, net.morimekta.providence.descriptor.PMessageDescriptor<M,F> descriptor, ProvidenceJdbi.MappedField<F>... fieldMapping)Bind to message using row mapper.static <M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField>
MessageRowMapper<M,F>toMessage(net.morimekta.providence.descriptor.PMessageDescriptor<M,F> descriptor, ProvidenceJdbi.MappedField<F>... fieldMapping)Bind to message using row mapper.static <F extends net.morimekta.providence.descriptor.PField>
ProvidenceJdbi.MappedField<F>withColumn(F field)With column mapped to field using the field name.static <F extends net.morimekta.providence.descriptor.PField>
ProvidenceJdbi.MappedField<F>withColumn(java.lang.String name, F field)With column mapped to field.static ProvidenceJdbi.FieldTypewithType(net.morimekta.providence.descriptor.PField field, int type)With field mapped to SQL type.
-
-
-
Method Detail
-
toField
public static <M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField> MessageFieldArgument<M,F> toField(M message, F field)
Bind to the given field for the message.- Type Parameters:
M- The message type.F- The message field 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,F>,F extends net.morimekta.providence.descriptor.PField> MessageFieldArgument<M,F> toField(M message, F field, int type)
Bind to the given field for the message.- Type Parameters:
M- The message type.F- The message field 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 <F extends net.morimekta.providence.descriptor.PField> ProvidenceJdbi.MappedField<F> columnsFromAllFields()
With all column with default types.- Type Parameters:
F- The message field type.- Returns:
- The mapped field.
-
withColumn
public static <F extends net.morimekta.providence.descriptor.PField> ProvidenceJdbi.MappedField<F> withColumn(F field)
With column mapped to field using the field name.- Type Parameters:
F- The message field type.- Parameters:
field- Field it is mapped to.- Returns:
- The mapped field.
-
withColumn
public static <F extends net.morimekta.providence.descriptor.PField> ProvidenceJdbi.MappedField<F> withColumn(java.lang.String name, F field)
With column mapped to field.- Type Parameters:
F- The message field 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,F>,F extends net.morimekta.providence.descriptor.PField> MessageRowMapper<M,F> toMessage(@Nonnull net.morimekta.providence.descriptor.PMessageDescriptor<M,F> descriptor, @Nonnull ProvidenceJdbi.MappedField<F>... fieldMapping)
Bind to message using row mapper.- Type Parameters:
M- The message type.F- The message field 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,F>,F extends net.morimekta.providence.descriptor.PField> MessageRowMapper<M,F> toMessage(@Nonnull java.lang.String tableName, @Nonnull net.morimekta.providence.descriptor.PMessageDescriptor<M,F> descriptor, @Nonnull ProvidenceJdbi.MappedField<F>... fieldMapping)
Bind to message using row mapper.- Type Parameters:
M- The message type.F- The message field 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 ProvidenceJdbi.FieldType withType(net.morimekta.providence.descriptor.PField field, int type)
With field mapped to SQL type.- Parameters:
field- The field to be mapped.type- The SQL type. SeeTypes.- Returns:
- The field type mapping.
-
forMessage
public static <M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField> MessageNamedArgumentFinder<M,F> forMessage(@Nonnull M message, @Nonnull ProvidenceJdbi.FieldType... fieldTypes)
Get named argument finder for message.- Type Parameters:
M- The message type.F- The message field type.- Parameters:
message- The message to map fields from.fieldTypes- Field type mappings.- Returns:
- The named argument finder.
-
forMessage
public static <M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField> MessageNamedArgumentFinder<M,F> forMessage(@Nonnull java.lang.String prefix, @Nonnull M message, @Nonnull ProvidenceJdbi.FieldType... fieldTypes)
Get named argument finder for message.- Type Parameters:
M- The message type.F- The message field type.- Parameters:
prefix- Name prefix for naming distinction.message- The message to map fields from.fieldTypes- Field type mappings.- Returns:
- The named argument finder.
-
-