Skip to the content.
package com.bookshop.structural.facade;

import com.bookshop.domain.Customer;
import java.math.BigDecimal;
import java.util.concurrent.atomic.AtomicLong;

/** Subsystem 2: taking the money. */
public class PaymentService {

    private final AtomicLong nextTransaction = new AtomicLong(1000);

    public String charge(Customer customer, BigDecimal amount) {
        return "txn-" + nextTransaction.incrementAndGet() + "-" + customer.id();
    }
}

Raw file