Package io.bytestreams.codec.core
Record Class EncodeResult
java.lang.Object
java.lang.Record
io.bytestreams.codec.core.EncodeResult
- Record Components:
count- the logical count in codec-specific units (e.g. code points, digits, items)bytes- the number of bytes written to the output stream
Result of an
encode operation, containing both the logical count and the
byte count written.
The count field represents the number of logical units processed, whose meaning is
codec-specific. For fixed-length codecs, this is the codec's configured length. For
variable-length (stream) codecs, this is the actual number of units in the encoded value.
Examples: code points for string codecs, hex digits for hex codecs, items for list codecs, bytes
for binary, boolean, and number codecs.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final EncodeResultAn empty result representing zero count and zero bytes written. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbytes()Returns the value of thebytesrecord component.intcount()Returns the value of thecountrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static EncodeResultofBytes(int bytes) Creates a result where the logical count equals the byte count.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
EMPTY
An empty result representing zero count and zero bytes written.
-
-
Constructor Details
-
EncodeResult
public EncodeResult(int count, int bytes) Creates a new EncodeResult.
-
-
Method Details
-
ofBytes
Creates a result where the logical count equals the byte count.- Parameters:
bytes- the number of bytes written (used as both count and bytes)- Returns:
- an EncodeResult where count == bytes
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
count
public int count()Returns the value of thecountrecord component.- Returns:
- the value of the
countrecord component
-
bytes
public int bytes()Returns the value of thebytesrecord component.- Returns:
- the value of the
bytesrecord component
-