java.lang.Object
java.lang.Record
dev.hloth.zgztransport.Subscription
- Record Components:
startsAt- the first day of validityendsAt- the last day of validityunknown1- bytes 4 and 5, big-endian, always0000so farunknown2- bytes 6 to 9, big-endianlastUsedAt- the last use the pass recorded, absent while it is unused
- All Implemented Interfaces:
Encodable
public record Subscription(CardDate startsAt, CardDate endsAt, int unknown1, long unknown2, Optional<CardDateTime> lastUsedAt)
extends Record
implements Encodable
Block 13 or 17 of a personal card, which the card copies into block 14 or 18.
Several fields have not been worked out yet and are named after the bytes
they hold.
-
Constructor Summary
ConstructorsConstructorDescriptionSubscription(CardDate startsAt, CardDate endsAt, int unknown1, long unknown2, Optional<CardDateTime> lastUsedAt) Checks the ranges of the numeric fields and that the others are present. -
Method Summary
Modifier and TypeMethodDescriptionstatic Subscriptiondecode(byte[] block) Decodes block 13 or 17.byte[]encode()Encodes this subscription into block 13 or 17, with its checksum.endsAt()Returns the value of theendsAtrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thelastUsedAtrecord component.startsAt()Returns the value of thestartsAtrecord component.final StringtoString()Returns a string representation of this record class.intunknown1()Returns the value of theunknown1record component.longunknown2()Returns the value of theunknown2record component.
-
Constructor Details
-
Subscription
public Subscription(CardDate startsAt, CardDate endsAt, int unknown1, long unknown2, Optional<CardDateTime> lastUsedAt) Checks the ranges of the numeric fields and that the others are present.- Throws:
IllegalArgumentException- if a field is outside the range its bytes allowNullPointerException- if a field is null
-
-
Method Details
-
decode
Decodes block 13 or 17.- Parameters:
block- the sixteen bytes- Returns:
- the subscription
- Throws:
CardFormatException- if the block is not sixteen bytes, its checksum does not match or a date is out of range
-
encode
public byte[] encode()Encodes this subscription into block 13 or 17, with its checksum. -
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
startsAt
Returns the value of thestartsAtrecord component.- Returns:
- the value of the
startsAtrecord component
-
endsAt
Returns the value of theendsAtrecord component.- Returns:
- the value of the
endsAtrecord component
-
unknown1
public int unknown1()Returns the value of theunknown1record component.- Returns:
- the value of the
unknown1record component
-
unknown2
public long unknown2()Returns the value of theunknown2record component.- Returns:
- the value of the
unknown2record component
-
lastUsedAt
Returns the value of thelastUsedAtrecord component.- Returns:
- the value of the
lastUsedAtrecord component
-