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 typeV
and an index field of typeF
.The
ValueBridge
interface is a simpler version ofPropertyBridge
, in which no property metadata is available and a given input value can only be mapped to a single field, in particular.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
close()
Close any resource before the bridge is discarded.default V
fromIndexedValue(F value, ValueBridgeFromIndexedValueContext context)
Transform the given indexed field value to the corresponding POJO-extracted value.default boolean
isCompatibleWith(ValueBridge<?,?> other)
default F
parse(String value)
Parse an input String to the raw index field value.F
toIndexedValue(V value, ValueBridgeToIndexedValueContext context)
Transform the given POJO-extracted value into the value of the indexed field.
-
-
-
Method Detail
-
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 beextended
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 beextended
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.
-
isCompatibleWith
default boolean isCompatibleWith(ValueBridge<?,?> other)
- Parameters:
other
- AnotherValueBridge
, nevernull
.- Returns:
true
if the given object is also aValueBridge
that behaves exactly the same as this object, i.e. itstoIndexedValue(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 interfaceAutoCloseable
-
-