Record Class Subscription

java.lang.Object
java.lang.Record
dev.hloth.zgztransport.Subscription
Record Components:
startsAt - the first day of validity
endsAt - the last day of validity
unknown1 - bytes 4 and 5, big-endian, always 0000 so far
unknown2 - bytes 6 to 9, big-endian
lastUsedAt - 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 Details

  • Method Details

    • decode

      public static Subscription decode(byte[] block)
      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.
      Specified by:
      encode in interface Encodable
      Returns:
      the sixteen bytes
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • startsAt

      public CardDate startsAt()
      Returns the value of the startsAt record component.
      Returns:
      the value of the startsAt record component
    • endsAt

      public CardDate endsAt()
      Returns the value of the endsAt record component.
      Returns:
      the value of the endsAt record component
    • unknown1

      public int unknown1()
      Returns the value of the unknown1 record component.
      Returns:
      the value of the unknown1 record component
    • unknown2

      public long unknown2()
      Returns the value of the unknown2 record component.
      Returns:
      the value of the unknown2 record component
    • lastUsedAt

      public Optional<CardDateTime> lastUsedAt()
      Returns the value of the lastUsedAt record component.
      Returns:
      the value of the lastUsedAt record component