Countries.java
/*
* Copyright © 2012-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.mirrors;
import java.util.Locale;
import java.util.ResourceBundle;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
/**
* This domain class represents a country.
*
* @author <a href="mailto:gene@ctan.org">Gerd Neugebauer</a>
*/
@Entity
@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class Countries {
/**
* The field <code>bundleDe</code> contains the translation to German.
*/
static ResourceBundle bundleDe =
ResourceBundle.getBundle("org.ctan.site.domain.mirrors.Countries",
Locale.GERMAN);
/**
* The field <code>id</code> contains the id.
*/
@Id
@GeneratedValue
private Long id;
/**
* The field <code>name</code> contains the name of the country in its own
* language.
*/
@Column(length = 255, nullable = false)
private String name;
/**
* The field <code>nameEnglish</code> contains the name of the country in
* English.
*/
@Column(length = 255, name = "name_english")
private String nameEnglish;
/**
* The field <code>continent</code> contains the reference to the continent.
*/
@ManyToOne
private Continents continent;
/**
* The method <code>getName</code> provides means to get the country in the
* given language.
*
* @param locale the language code
* @return the name of the country
*/
public String getName(String locale) {
if ("de".equals(locale)) {
return bundleDe.getString(Long.toString(id));
}
return nameEnglish;
}
/**
* {@inheritDoc}
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return nameEnglish;
}
}