Record Class SubscriptionMetadata

java.lang.Object
java.lang.Record
dev.hloth.zgztransport.SubscriptionMetadata
Record Components:
productId - byte 0, which tells the products of one card apart
unknown1 - byte 1, always 1 so far
purchasedAt - when the product was bought
unknown2 - bytes 4 to 7, big-endian, always 00210000 so far
validityDays - how many days the product is valid for
unknown3 - bytes 10 to 14, big-endian, always 0021000000 so far
All Implemented Interfaces:
Encodable

public record SubscriptionMetadata(int productId, int unknown1, CardDate purchasedAt, long unknown2, int validityDays, long unknown3) extends Record implements Encodable
Block 12 or 16 of a personal card, which describes one subscription product the card carries. Several fields have not been worked out yet and are named after the bytes they hold.
  • Constructor Details

    • SubscriptionMetadata

      public SubscriptionMetadata(int productId, int unknown1, CardDate purchasedAt, long unknown2, int validityDays, long unknown3)
      Checks the ranges of the numeric fields and that the date is present.
      Throws:
      IllegalArgumentException - if a field is outside the range its bytes allow
      NullPointerException - if the date is null
  • Method Details

    • decode

      public static SubscriptionMetadata decode(byte[] block)
      Decodes block 12 or 16.
      Parameters:
      block - the sixteen bytes
      Returns:
      the metadata
      Throws:
      CardFormatException - if the block is not sixteen bytes, its checksum does not match or the purchase date is out of range
    • encode

      public byte[] encode()
      Encodes this metadata into block 12 or 16, 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.
    • productId

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

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

      public CardDate purchasedAt()
      Returns the value of the purchasedAt record component.
      Returns:
      the value of the purchasedAt record component
    • unknown2

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

      public int validityDays()
      Returns the value of the validityDays record component.
      Returns:
      the value of the validityDays record component
    • unknown3

      public long unknown3()
      Returns the value of the unknown3 record component.
      Returns:
      the value of the unknown3 record component