Package io.bytestreams.codec.core.util
Interface Converter<V,U>
- Type Parameters:
V- the source typeU- the target type
- All Known Implementing Classes:
BiMap
public interface Converter<V,U>
A bidirectional conversion between two types.
Converters transform values in both directions: to(Object) converts from V
to U, and from(Object) converts from U back to V. Unlike a
mathematical bijection, conversions are not required to be strictly one-to-one.
Converters can be composed using andThen(Converter) or created from function pairs
using Converters.of.
-
Method Summary
Modifier and TypeMethodDescriptionReturns a composed converter that first applies this converter, then applies theafterconverter.Converts a value from the target type back to the source type.Converts a value from the source type to the target type.
-
Method Details
-
to
Converts a value from the source type to the target type.- Parameters:
value- the source value- Returns:
- the converted target value
-
from
Converts a value from the target type back to the source type.- Parameters:
value- the target value- Returns:
- the converted source value
-
andThen
Returns a composed converter that first applies this converter, then applies theafterconverter.- Type Parameters:
T- the target type of the resulting converter- Parameters:
after- the converter to apply after this one- Returns:
- the composed converter
-