AuthorEmail.java

/*
 * Copyright © 2016-2025 The CTAN Team and individual authors
 *
 * This file is distributed under the 3-clause BSD license.
 * See file LICENSE for details.
 */
package org.ctan.site.domain.catalogue;

import org.ctan.site.domain.AbstractEntity;

import com.fasterxml.jackson.annotation.JsonManagedReference;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder.Default;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

/**
 * This is the domain class for an author's email in the CTAN Catalogue.
 *
 * @author <a href="mailto:gene@ctan.org">Gerd Neugebauer</a>
 */
@Table(name = "author_email")
@Data
@Entity
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@SuppressFBWarnings(value = "EI_EXPOSE_REP")
public class AuthorEmail extends AbstractEntity {

    /**
     * The field <code>address</code> contains the email address.
     */
    @Column(length = 255, nullable = false)
    private String address;

    /**
     * The field <code>inactive</code> contains the indicator for inactive email
     * addresses. An email address marked this way should not be used.
     */
    @Column
    @Default
    private Boolean inactive = Boolean.FALSE;

    /**
     * The field <code>note</code> contains internal notes.
     */
    @Column(length = 1024)
    private String note;

    /**
     * The field <code>author</code> contains the reference to the author.
     */
    @ManyToOne(optional = false)
    @JsonManagedReference
    @EqualsAndHashCode.Exclude
    private Author author;
    // static belongsTo = [author: Author]

    /**
     * {@inheritDoc}
     *
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {

        return address;
    }
}