package tech.letscode.awsexplorer.domain.model;

import org.apache.commons.lang3.Validate;

import javax.annotation.Nonnull;
import java.util.List;
import java.util.function.Consumer;

/**
 * @author Oleg Pavlov <oleg.pavlov@aol.com>
 */
public class Bucket
{
    private String name;

    private List<Directory> directories;

    public Bucket(@Nonnull String name, List<Directory> directories)
    {
        Validate.notNull(name, "name is required");
        this.name = name;
        this.directories = directories;
    }

    @Nonnull
    public String name()
    {
        return this.name;
    }

    public void visitDirectories(@Nonnull Consumer<Directory> consumer)
    {
        Validate.notNull(consumer, "consumer is required");
        if (this.directories != null)
        {
            this.directories.forEach(consumer);
        }
    }
}
