package inn.ocsf.bee.freigeld.core.model;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;
import java.util.UUID;
import java.util.stream.Collectors;

public interface BankAccount {

    UUID getId();

    UUID getOwnerId();

    Long getOverall();

    @Nullable
    Collection<Coin> getCoins();

    @Nullable
    Coin extractOne(@NotNull UUID coinId);

    default Collection<Coin> extract(@NotNull Collection<UUID> coinIds) {
        return coinIds.stream().map(this::extractOne).collect(Collectors.toList());
    }

    void acceptOne(@NotNull Coin coin);

    default void accept(@NotNull Collection<Coin> coins) {
        coins.forEach(this::acceptOne);
    }
}
