java.lang.Object
dev.hloth.zgztransport.TransactionBuilder
Collects the fields of a
Transaction one at a time, which reads
better than a constructor of ten arguments and cannot mix up the counters
that sit next to each other.
The amount, the counters and the network flag start at zero, the values a top
up carries. The product, the stop, the route, the kind and the timestamp have
no default and have to be set. Nothing is checked until build()
runs.
Transaction ride = Transaction.builder().cardType(CardType.AVANZA_TOP_UP).amount(550).consecutivePayments(1)
.stop(new Stop.Urban(500)).route(new Route(31)).kind(new TransactionKind.Journey(Direction.TWO))
.runCounter(7).createdAt(CardDateTime.of(2026, 8, 26, 9, 41, 27)).sequence(1).build();
-
Method Summary
Modifier and TypeMethodDescriptionamount(int amount) build()Builds the transaction.consecutivePayments(int consecutivePayments) createdAt(CardDateTime createdAt) kind(TransactionKind kind) networkFlag(int networkFlag) runCounter(int runCounter) sequence(int sequence)
-
Method Details
-
cardType
-
networkFlag
-
amount
-
consecutivePayments
-
stop
-
route
-
kind
-
runCounter
-
createdAt
-
sequence
-
build
Builds the transaction.- Returns:
- the transaction
- Throws:
IllegalArgumentException- if a field is outside the range its byte allowsNullPointerException- if a field that has no default was not set
-