package dev.morphia.test.aggregation.model;

import java.util.List;

import dev.morphia.annotations.Entity;
import dev.morphia.annotations.Id;

import org.bson.types.ObjectId;

import static java.lang.String.format;
import static java.util.Arrays.asList;

@Entity(value = "books", useDiscriminator = false)
public final class Book {
    @Id
    private ObjectId id;
    private String title;
    private String author;
    private Integer copies;
    private List<String> tags;

    private Book() {
    }

    public Book(String title, String author, Integer copies, String... tags) {
        this.title = title;
        this.author = author;
        this.copies = copies;
        this.tags = asList(tags);
    }

    public Book(String title, String author) {
        this.title = title;
        this.author = author;
    }

    public ObjectId getId() {
        return id;
    }

    public String getTitle() {
        return title;
    }

    public String getAuthor() {
        return author;
    }

    public Integer getCopies() {
        return copies;
    }

    public List<String> getTags() {
        return tags;
    }

    @Override
    public String toString() {
        return format("Book{title='%s', author='%s', copies=%d, tags=%s}", title, author, copies, tags);
    }
}
