Package io.bytestreams.codec.iso8583
Class BitmappedCodecBuilder.DataFieldBuilder<T extends Bitmapped>
java.lang.Object
io.bytestreams.codec.iso8583.BitmappedCodecBuilder.DataFieldBuilder<T>
- Type Parameters:
T- the bitmapped object type
- Enclosing class:
BitmappedCodecBuilder<T extends Bitmapped>
Phase 2 builder for adding bitmap-driven data fields using
BitmappedFieldSpec.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the codec.dataField(BitmappedFieldSpec<T, V> spec) Adds an optional data field using aBitmappedFieldSpec.Rejects a data field by throwing if the bit is set.skip(int bit, io.bytestreams.codec.core.Codec<V> codec) Skips a data field by reading and discarding its value during decode.
-
Method Details
-
dataField
Adds an optional data field using aBitmappedFieldSpec.The bit index and presence predicate are derived from the spec. The bit index must not be an extension bit or a duplicate of an already-registered bit.
- Type Parameters:
V- the field value type- Parameters:
spec- the bitmapped field specification- Returns:
- this builder
- Throws:
IllegalArgumentException- if the spec's bit index is an extension bit or duplicate
-
skip
public <V> BitmappedCodecBuilder.DataFieldBuilder<T> skip(int bit, io.bytestreams.codec.core.Codec<V> codec) Skips a data field by reading and discarding its value during decode. During encode, the field is written if the bit is set in the bitmap.Use this for fields that exist on the wire but whose values are not needed.
- Parameters:
bit- the bitmap bit indexcodec- the codec to read/write the field (value is discarded on decode)- Returns:
- this builder
- Throws:
IllegalArgumentException- if the bit index is an extension bit, not positive, or duplicate
-
reject
Rejects a data field by throwing if the bit is set. Use this for fields that should never appear on the wire.- Parameters:
bit- the bitmap bit indexname- descriptive name for error messages- Returns:
- this builder
- Throws:
IllegalArgumentException- if the bit index is an extension bit, not positive, or duplicate
-
build
Builds the codec. Sorts data fields by bit index and validates the bitmap during decode.- Returns:
- the constructed
BitmappedCodec
-