java.lang.Object
java.lang.Record
dev.hloth.zgztransport.Card
- Record Components:
uid- the UID of block 0cardType- the product of block 1id- the printed id of block 2balance- the balance of blocks 8 and 9, always zero on a personal cardtransactions- the last six transactions, oldest firstjourneySummary- block 10, absent on a personal card and before the first journeyproducts- the subscription products, empty on a top up card
public record Card(Uid uid, CardType cardType, CardId id, Balance balance, List<Transaction> transactions, Optional<JourneySummary> journeySummary, List<Product> products)
extends Record
Everything a dump of one card holds.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe first block a dump must reach to hold everything this decodes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbalance()Returns the value of thebalancerecord component.cardType()Returns the value of thecardTyperecord component.static Carddecode(byte[] bytes) Decodes a dump of either card, as MIFARE Classic Tool or a Proxmark writes it.static CardDecodes a dump of either card.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.Returns the value of thejourneySummaryrecord component.products()Returns the value of theproductsrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thetransactionsrecord component.uid()Returns the value of theuidrecord component.
-
Field Details
-
LAST_USED_BLOCK
public static final int LAST_USED_BLOCKThe first block a dump must reach to hold everything this decodes.- See Also:
-
-
Constructor Details
-
Card
public Card(Uid uid, CardType cardType, CardId id, Balance balance, List<Transaction> transactions, Optional<JourneySummary> journeySummary, List<Product> products) Checks that every field is present and copies the lists.- Throws:
NullPointerException- if a field is null
-
-
Method Details
-
decode
Decodes a dump of either card, as MIFARE Classic Tool or a Proxmark writes it. A dump that stops after block 33 is enough, and anything past it is ignored.- Parameters:
bytes- the blocks, one after another from block 0- Returns:
- the card
- Throws:
CardFormatException- if the bytes are not whole blocks or the card does not decode
-
decode
Decodes a dump of either card.- Parameters:
dump- the blocks, from block 0- Returns:
- the card
- Throws:
CardFormatException- if the dump stops before block 33, carries no known SAK, holds two different balance blocks, or any block it reads does not decode
-
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 withObjects::equals(Object,Object). -
uid
Returns the value of theuidrecord component.- Returns:
- the value of the
uidrecord component
-
cardType
Returns the value of thecardTyperecord component.- Returns:
- the value of the
cardTyperecord component
-
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
balance
Returns the value of thebalancerecord component.- Returns:
- the value of the
balancerecord component
-
transactions
Returns the value of thetransactionsrecord component.- Returns:
- the value of the
transactionsrecord component
-
journeySummary
Returns the value of thejourneySummaryrecord component.- Returns:
- the value of the
journeySummaryrecord component
-
products
Returns the value of theproductsrecord component.- Returns:
- the value of the
productsrecord component
-