// Path: mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/EmailState.java
// public enum EmailState implements ObjectState {
//     CREATED,
//     SENT,
//     DELIVERED,
//     READ,
//     FAILED,
//     REPLIED,
//     DELETED
// }


import com.apssouza.eventsourcing.aggregates.EmailState;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
package com.apssouza.eventsourcing.entities;


/**
 * Email entity
 *
 * @author apssouza
 */
@Entity
public class Email {

    @Id
    @GeneratedValue
    private long id;

    @NotNull
    private long authId;

    @NotNull
    @Size(min = 2, max = 256)
    private String name;

    @org.hibernate.validator.constraints.Email
    @NotNull
    @Column(unique = true)
    private String email;
    
    private EmailState state;

    @Version
    private long version;

    public Email() {
    }

    public Email(String name, String email, EmailState state) {
        this.name = name;
        this.email = email;
        this.state = state;
    }

    public Email(long id, String name, String email, EmailState state) {
        this(name, email,state);
        this.id = id;
    }

// Path: mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/EmailState.java
// public enum EmailState implements ObjectState {
//     CREATED,
//     SENT,
//     DELIVERED,
//     READ,
//     FAILED,
//     REPLIED,
//     DELETED
// }


// Path: mail-service/src/main/java/com/apssouza/eventsourcing/entities/Email.java
import com.apssouza.eventsourcing.aggregates.EmailState;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

package com.apssouza.eventsourcing.entities;


/**
 * Email entity
 *
 * @author apssouza
 */
@Entity
public class Email {

    @Id
    @GeneratedValue
    private long id;

    @NotNull
    private long authId;

    @NotNull
    @Size(min = 2, max = 256)
    private String name;

    @org.hibernate.validator.constraints.Email
    @NotNull
    @Column(unique = true)
    private String email;
    
    private EmailState state;

    @Version
    private long version;

    public Email() {
    }

    public Email(String name, String email, EmailState state) {
        this.name = name;
        this.email = email;
        this.state = state;
    }

    public Email(long id, String name, String email, EmailState state) {
        this(name, email,state);
        this.id = id;
    }

    public EmailState getState() {