Interface JavaType<T>

    • Method Detail

      • getJavaType

        default Type getJavaType()
        Get the Java type (a Type object) described by this JavaType.
        See Also:
        getJavaTypeClass()
      • getJavaTypeClass

        default Class<T> getJavaTypeClass()
        Get the Java type (the Class object) described by this JavaType.
        See Also:
        getJavaType()
      • getDefaultValue

        default T getDefaultValue()
        Get this Java type's default value.
        Returns:
        The default value.
      • getRecommendedJdbcType

        JdbcType getRecommendedJdbcType​(JdbcTypeIndicators context)
        Obtain the "recommended" SQL type descriptor for this Java type. Often, but not always, the source of this recommendation is the JDBC specification.
        Parameters:
        context - Contextual information
        Returns:
        The recommended SQL type descriptor
      • getDefaultSqlLength

        default long getDefaultSqlLength​(Dialect dialect,
                                         JdbcType jdbcType)
        The default column length when this Java type is mapped to a SQL data type which is parametrized by length, for example Types.VARCHAR.
        Returns:
        Size.DEFAULT_LENGTH unless overridden
      • getDefaultSqlPrecision

        default int getDefaultSqlPrecision​(Dialect dialect,
                                           JdbcType jdbcType)
        The default column precision when this Java type is mapped to a SQL data type which is parametrized by precision, for example Types.DECIMAL.
        Returns:
        Size.DEFAULT_PRECISION unless overridden
      • getDefaultSqlScale

        default int getDefaultSqlScale​(Dialect dialect,
                                       JdbcType jdbcType)
        The default column scale when this Java type is mapped to a SQL data type which is parametrized by scale, for example Types.DECIMAL.
        Returns:
        Size.DEFAULT_SCALE unless overridden
      • getComparator

        default Comparator<T> getComparator()
        Retrieve the natural comparator for this type.
      • extractHashCode

        default int extractHashCode​(T value)
        Extract a proper hash code for the given value.
        Parameters:
        value - The value for which to extract a hash code.
        Returns:
        The extracted hash code.
      • areEqual

        default boolean areEqual​(T one,
                                 T another)
        Determine if two instances are equal
        Parameters:
        one - One instance
        another - The other instance
        Returns:
        True if the two are considered equal; false otherwise.
      • extractLoggableRepresentation

        default String extractLoggableRepresentation​(T value)
        Extract a loggable representation of the given value.
        Parameters:
        value - The value for which to extract a loggable representation.
        Returns:
        The loggable representation
      • toString

        default String toString​(T value)
      • appendEncodedString

        default void appendEncodedString​(SqlAppender sb,
                                         T value)
        Appends the value to the SqlAppender in an encoded format that can be decoded again by fromEncodedString(CharSequence, int, int). Implementers do not need to care about escaping. This is similar to toString(Object), with the difference that the aim of this method is encoding to the appender.
        Since:
        6.2
      • fromEncodedString

        default T fromEncodedString​(CharSequence charSequence,
                                    int start,
                                    int end)
        Reads the encoded value from the char sequence start index until the end index and returns the decoded value. Implementers do not need to care about escaping. This is similar to fromString(CharSequence), with the difference that the aim of this method is decoding from a range within an existing char sequence.
        Since:
        6.2
      • unwrap

        <X> X unwrap​(T value,
                     Class<X> type,
                     WrapperOptions options)
        Unwrap an instance of our handled Java type into the requested type.

        As an example, if this is a JavaType<Integer> and we are asked to unwrap the Integer value as a Long, we would return something like Long.valueOf( value.longValue() ).

        Intended use is during PreparedStatement binding.

        Type Parameters:
        X - The conversion type.
        Parameters:
        value - The value to unwrap
        type - The type as which to unwrap
        options - The options
        Returns:
        The unwrapped value.
      • wrap

        <X> T wrap​(X value,
                   WrapperOptions options)
        Wrap a value as our handled Java type.

        Intended use is during ResultSet extraction.

        Type Parameters:
        X - The conversion type.
        Parameters:
        value - The value to wrap.
        options - The options
        Returns:
        The wrapped value.
      • isWider

        default boolean isWider​(JavaType<?> javaType)
        Determines if this Java type is wider than the given Java type, that is, if the given type can be safely widened to this type.