TopicDetail.java

/*
 * Copyright © 2023-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 edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

/**
 * The class <code>TopicDetail</code> contains a domain class for a single
 * detail in one language for a topic in the Catalogue.
 *
 * @author <a href="mailto:gene@ctan.org">Gerd Neugebauer</a>
 */
@Entity
@Data
@Table(name = "topic_detail")
@EqualsAndHashCode(callSuper = false)
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@SuppressFBWarnings(value = "EI_EXPOSE_REP")
public class TopicDetail extends AbstractEntity {

    /**
     * The field <code>lang</code> contains the language as 2-letter ISO 639-1
     * code.
     */
    @Column(length = 8)
    private String lang;

    /**
     * The field <code>title</code> contains the title in the given language.
     */
    @Column(length = 512, nullable = false)
    private String title;

    /**
     * The field <code>description</code> contains the description in the given
     * language.
     */
    @Column(length = 2048, nullable = false)
    private String description;

    /**
     * The field <code>teaser</code> contains the teaser text.
     */
    @Column(length = 1024, nullable = false)
    private String teaser;

    /**
     * The field <code>detail</code> contains the detailed description in the
     * given language.
     */
    @Column(length = 512, nullable = false)
    private String detail;

    @ManyToOne(fetch = FetchType.LAZY)
    private Topic topic;
    // static belongsTo = [topic: Topic]

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

        return lang + ": " + detail;
    }
}