package com.ankurm.streams; /** A card transaction. */ public record Txn(String card, double amount, int hour, String category) { /** Wire format: {@code card,amount,hour,category}. Plain text keeps the serde trivial to read. */ public String encode() { return card + "," + amount + "," + hour + "," + category; } public static Txn decode(String s) { String[] p = s.split(",", 4); return new Txn(p[0], Double.parseDouble(p[1]), Integer.parseInt(p[2]), p[3]); } }