ВопросSeniorIT One19 просмотров

Оценить модель для использования в ArrayList, HashMap, TreeSet static public final class Transaction<T extends Number> implements Comparable<Transaction> { private final T id; private final Double amount; private final java.util.Date timestamp; public Transaction(T id, double amount, java.util.Date timestamp) { this.id = id; this.amount = amount; this.timestamp = timestamp; } public T getId() { return id; } public Double getAmount() { return amount; } public java.util.Date getTimestamp() { return timestamp; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Transaction t)) return false; return id == t.id && Double.compare(amount, t.amount) == 0 && timestamp.equals(t.timestamp); } @Override public int hashCode() { return Objects.hash(id, timestamp); } @Override public int compareTo(Transaction other) { return this.timestamp.compareTo(other.timestamp); } }