java.lang.Object
java.lang.Record
dev.hloth.zgztransport.SubscriptionMetadata
- Record Components:
productId- byte 0, which tells the products of one card apartunknown1- byte 1, always1so farpurchasedAt- when the product was boughtunknown2- bytes 4 to 7, big-endian, always00210000so farvalidityDays- how many days the product is valid forunknown3- bytes 10 to 14, big-endian, always0021000000so 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 Summary
ConstructorsConstructorDescriptionSubscriptionMetadata(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. -
Method Summary
Modifier and TypeMethodDescriptionstatic SubscriptionMetadatadecode(byte[] block) Decodes block 12 or 16.byte[]encode()Encodes this metadata into block 12 or 16, with its checksum.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of theproductIdrecord component.Returns the value of thepurchasedAtrecord 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.longunknown3()Returns the value of theunknown3record component.intReturns the value of thevalidityDaysrecord component.
-
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 allowNullPointerException- if the date is null
-
-
Method Details
-
decode
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. -
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 '=='. -
productId
public int productId()Returns the value of theproductIdrecord component.- Returns:
- the value of the
productIdrecord component
-
unknown1
public int unknown1()Returns the value of theunknown1record component.- Returns:
- the value of the
unknown1record component
-
purchasedAt
Returns the value of thepurchasedAtrecord component.- Returns:
- the value of the
purchasedAtrecord component
-
unknown2
public long unknown2()Returns the value of theunknown2record component.- Returns:
- the value of the
unknown2record component
-
validityDays
public int validityDays()Returns the value of thevalidityDaysrecord component.- Returns:
- the value of the
validityDaysrecord component
-
unknown3
public long unknown3()Returns the value of theunknown3record component.- Returns:
- the value of the
unknown3record component
-