Class ProvidenceJdbi


  • public class ProvidenceJdbi
    extends java.lang.Object
    Utility class and helper to make mappers and argument helpers for JDBI queries and updates.
    • Constructor Detail

      • ProvidenceJdbi

        public ProvidenceJdbi()
    • Method Detail

      • toField

        public static <M extends PMessage<M,​F>,​F extends PFieldMessageFieldArgument<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 PMessage<M,​F>,​F extends PFieldMessageFieldArgument<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 PFieldProvidenceJdbi.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 PFieldProvidenceJdbi.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 PFieldProvidenceJdbi.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 PMessage<M,​F>,​F extends PFieldMessageRowMapper<M,​F> toMessage​(@Nonnull
                                                                                                                   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 PMessage<M,​F>,​F extends PFieldMessageRowMapper<M,​F> toMessage​(@Nonnull
                                                                                                                   java.lang.String tableName,
                                                                                                                   @Nonnull
                                                                                                                   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​(PField field,
                                                        int type)
        With field mapped to SQL type.
        Parameters:
        field - The field to be mapped.
        type - The SQL type. See Types.
        Returns:
        The field type mapping.
      • forMessage

        public static <M extends PMessage<M,​F>,​F extends PFieldMessageNamedArgumentFinder<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 PMessage<M,​F>,​F extends PFieldMessageNamedArgumentFinder<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.