Package io.bytestreams.codec.iso8583
Interface BitmappedFieldSpec<T extends Bitmapped,V>
- Type Parameters:
T- the object type (must implementBitmapped)V- the field value type
- All Superinterfaces:
io.bytestreams.codec.core.FieldSpec<T,V>
public interface BitmappedFieldSpec<T extends Bitmapped,V>
extends io.bytestreams.codec.core.FieldSpec<T,V>
A
FieldSpec that adds a bitmap bit index and automatic bitmap management.
When FieldSpec.set(Object, Object) is called, the bitmap is automatically updated: non-null
values set the bit, null values clear it. The FieldSpec.presence() predicate checks the bitmap bit
during encoding and decoding.
class IsoMessage extends DataObject implements Bitmapped {
static final BitmappedFieldSpec<IsoMessage, String> PAN =
BitmappedFieldSpec.of(2, DataObject.field("pan", panCodec));
public String getPan() { return get(PAN); }
public void setPan(String pan) { set(PAN, pan); }
}
-
Method Summary
Modifier and TypeMethodDescriptionintbit()Returns the bitmap bit index for this field.static <T extends Bitmapped,V>
BitmappedFieldSpec<T, V> of(int bit, io.bytestreams.codec.core.FieldSpec<T, V> delegate) Wraps aFieldSpecwith bitmap management at the given bit index.Methods inherited from interface io.bytestreams.codec.core.FieldSpec
codec, get, name, presence, set
-
Method Details
-
bit
int bit()Returns the bitmap bit index for this field. Must be positive (bits are 1-indexed).- Returns:
- the bit index, always > 0
-
of
static <T extends Bitmapped,V> BitmappedFieldSpec<T,V> of(int bit, io.bytestreams.codec.core.FieldSpec<T, V> delegate) Wraps aFieldSpecwith bitmap management at the given bit index.The returned spec delegates to the wrapped spec for get/set, and additionally sets or clears the bitmap bit when a value is set.
- Type Parameters:
T- the object type (must implement Bitmapped)V- the field value type- Parameters:
bit- the bitmap bit indexdelegate- the field spec to wrap- Returns:
- a new BitmappedFieldSpec
-