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
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 Summary
Modifier and TypeMethodDescriptiondefault void
close()
Close any resource before the bridge is discarded.default String
Format the value to a String.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 an input String to the raw index field value.toIndexedValue
(V value, ValueBridgeToIndexedValueContext context) Transform the given POJO-extracted value into the value of the indexed field.
-
Method Details
-
toIndexedValue
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
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
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
Format the value to a String.- Parameters:
value
- The value to format.- Returns:
- The formatted String.
-
isCompatibleWith
- 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
-