/* * Copyright @ 2013 CurisTEC, S.A.S. All Rights Reserved. */ package net.curisit.securis.db; import java.io.Serializable; import java.util.Objects; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.NamedQueries; import jakarta.persistence.NamedQuery; import jakarta.persistence.Table; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import net.curisit.securis.db.common.Metadata; /** * LicenseTypeMetadata *
* Single metadata entry attached to a {@link LicenseType}. * Composite PK: (license_type_id, key). * * Mapping details: * - Table: licensetype_metadata * - @JsonBackReference to avoid recursion with LicenseType.metadata. * - NamedQuery: list-licensetype-metadata by license type id. * * @author JRA * Last reviewed by JRA on Oct 5, 2025. */ @JsonAutoDetect @JsonInclude(Include.NON_NULL) @Entity @Table(name = "licensetype_metadata") @JsonIgnoreProperties(ignoreUnknown = true) @NamedQueries({ @NamedQuery(name = "list-licensetype-metadata", query = "SELECT a FROM LicenseTypeMetadata a where a.licenseType.id = :licenseTypeId") }) public class LicenseTypeMetadata implements Serializable, Metadata { private static final long serialVersionUID = 1L; /** PK part: owning license type. */ @Id @ManyToOne @JsonBackReference @JoinColumn(name = "license_type_id") private LicenseType licenseType; /** PK part: metadata key (quoted). */ @Id @Column(name = "\"key\"") private String key; /** Metadata value. */ private String value; /** Whether this key is mandatory for the license type. */ private boolean mandatory; // ---------------- Getters & setters ---------------- /** * getLicenseType
* Return owning license type. * * @return licenseType */ public LicenseType getLicenseType() { return licenseType; } /** * setLicenseType
* Set owning license type. * * @param licenseType */ public void setLicenseType(LicenseType licenseType) { this.licenseType = licenseType; } /** * getValue
* Return metadata value. * * @return value */ public String getValue() { return value; } /** * setValue
* Set metadata value. * * @param value */ public void setValue(String value) { this.value = value; } /** * getKey
* Return metadata key (PK part). * * @return key */ public String getKey() { return key; } /** * setKey
* Set metadata key (PK part). * * @param key */ public void setKey(String key) { this.key = key; } /** * isMandatory
* Return whether this entry is required. * * @return isMandatory */ public boolean isMandatory() { return mandatory; } /** * setMandatory
* Set whether this entry is required. * * @param mandatory */ public void setMandatory(boolean mandatory) { this.mandatory = mandatory; } // ---------------- Object methods ---------------- /** * equals
* Compare the current object with the given object * * @param object * @return isEquals */ @Override public boolean equals(Object obj) { if (!(obj instanceof LicenseTypeMetadata)) return false; LicenseTypeMetadata other = (LicenseTypeMetadata) obj; return Objects.equals(key, other.key) && Objects.equals(licenseType, other.licenseType); } /** * hashCode
* Get the object hashCode * * @return hashCode */ @Override public int hashCode() { return Objects.hash(key, licenseType); } /** * toString
* Get the string describing the current object * * @return object string */ @Override public String toString() { return String.format("LTMD (%s: %s)", key, value); } }