package br.com.studio2w.builders;

import br.com.studio2w.models.Ticket;
import br.com.studio2w.models.TicketStatus;
import br.com.studio2w.models.User;

import java.util.Calendar;
import java.util.Date;

/**
 * Created by andre on 15/04/2017.
 */
public class TicketBuilder {

    private String title;
    private String description;
    private Date creation;
    private User customer;
    private TicketStatus status;
    private User creator;


    public TicketBuilder withTitle(String title) {
        this.title = title;
        return this;
    };

    public TicketBuilder withDescription(String description) {
        this.description = description;
        return this;
    }

    public TicketBuilder withTodaysDate() {
        this.creation = Calendar.getInstance().getTime();
        return this;
    }

    public TicketBuilder withCreationDate(Date date) {
        this.creation = date;
        return this;
    }

    public TicketBuilder withCustomer(User user) {
        this.customer = user;
        return this;
    }

    public TicketBuilder withStatus(TicketStatus status) {
        this.status = status;
        return this;
    }

    public TicketBuilder createdBy(User user) {
        this.creator = user;
        return this;
    }

    public Ticket build() {
        Ticket ticket = new Ticket();

        ticket.setClosed(false);
        ticket.setTitle(title);
        ticket.setDescription(description);
        ticket.setCreation(creation);
        ticket.setCustomer(customer);
        ticket.setStatus(status);
        ticket.setCreator(creator);

        return ticket;
    }
}
