Interface ValueBridge<V,F>

Type Parameters:
V - The type of values on the POJO side of the bridge.
F - The type of raw index field values, on the index side of the bridge.
All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
ValueBridgeRef.UndefinedBridgeImplementationType

public interface ValueBridge<V,F> extends AutoCloseable
A bridge between a POJO-extracted value of type V and an index field of type F.

The ValueBridge interface is a simpler version of PropertyBridge, in which no property metadata is available and a given input value can only be mapped to a single field, in particular.

  • Method Details

    • toIndexedValue

      F toIndexedValue(V value, ValueBridgeToIndexedValueContext context)
      Transform the given POJO-extracted value into the value of the indexed field.
      Parameters:
      value - The POJO-extracted value to be transformed.
      context - A context that can be extended to a more useful type, giving access to such things as a Hibernate ORM SessionFactory (if using the Hibernate ORM mapper).
      Returns:
      The value of the indexed field.
    • fromIndexedValue

      default V fromIndexedValue(F value, ValueBridgeFromIndexedValueContext context)
      Transform the given indexed field value to the corresponding POJO-extracted value.
      Parameters:
      value - The value of the indexed field to be transformed.
      context - A context that can be extended to a more useful type, giving access to such things as a Hibernate ORM SessionFactory (if using the Hibernate ORM mapper).
      Returns:
      The POJO-extracted value.
      Throws:
      UnsupportedOperationException - If conversion is not supported.
    • parse

      default F parse(String value)
      Parse an input String to the raw index field value.
      Parameters:
      value - The value to parse.
      Returns:
      The raw index field value.
      Throws:
      RuntimeException - If the value cannot be parsed to the raw index field value.
    • format

      @Incubating default String format(F value)
      Format the value to a String.
      Parameters:
      value - The value to format.
      Returns:
      The formatted String.
    • isCompatibleWith

      default boolean isCompatibleWith(ValueBridge<?,?> other)
      Parameters:
      other - Another ValueBridge, never null.
      Returns:
      true if the given object is also a ValueBridge that behaves exactly the same as this object, i.e. its toIndexedValue(Object, ValueBridgeToIndexedValueContext) method is guaranteed to accept the same values as this object's and to always return the same value as this object's when given the same input. false otherwise, or when in doubt.
    • close

      default void close()
      Close any resource before the bridge is discarded.
      Specified by:
      close in interface AutoCloseable