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>

public static class BitmappedCodecBuilder.DataFieldBuilder<T extends Bitmapped> extends Object
Phase 2 builder for adding bitmap-driven data fields using BitmappedFieldSpec.
  • Method Details

    • dataField

      Adds an optional data field using a BitmappedFieldSpec.

      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 index
      codec - 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

      public BitmappedCodecBuilder.DataFieldBuilder<T> reject(int bit, String name)
      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 index
      name - descriptive name for error messages
      Returns:
      this builder
      Throws:
      IllegalArgumentException - if the bit index is an extension bit, not positive, or duplicate
    • build

      public BitmappedCodec<T> build()
      Builds the codec. Sorts data fields by bit index and validates the bitmap during decode.
      Returns:
      the constructed BitmappedCodec