Package io.bytestreams.codec.core
Class ChoiceCodec.Builder<V>
java.lang.Object
io.bytestreams.codec.core.ChoiceCodec.Builder<V>
- Type Parameters:
V- the base type of the discriminated union
- Enclosing class:
ChoiceCodec<V>
Builder for
ChoiceCodec.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the choice codec.<S extends V>
ChoiceCodec.Builder<V> Registers a class/codec pair.
-
Method Details
-
on
Registers a class/codec pair.- Type Parameters:
S- the subtype- Parameters:
type- the class to registercodec- the codec for values of this class- Returns:
- this builder
- Throws:
NullPointerException- if type or codec is nullIllegalArgumentException- if the type is already registered
-
build
Builds the choice codec.- Returns:
- a new choice codec
- Throws:
IllegalArgumentException- if no options have been registered
-