Currency.java

package com.tradecloud.domain.common;

import javax.persistence.*;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;


/**
 * @author pvzyl 10 Apr 2012
 *
 * <currency code="ZAR" name="Rand" />
 */
@Entity
//@Cacheable(value = "currency")
@Table(name = "currency", uniqueConstraints = {
        @UniqueConstraint(columnNames = {"code"})})
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "Currency")
public class Currency extends IntegratedStaticDataEntityBase {

    /**
     * UID.
     */
    private static final long serialVersionUID = -6163879797913915609L;

    public Currency(String currencyCode, String name) {
        setCode(currencyCode);
        setName(name);
    }

    public Currency(String currencyCode) {
        setCode(currencyCode);
    }

    public Currency() {
    }

    /**
     * This should eventually be removed when the Money class and other places use our currency.
     *
     * @param currency
     * @return
     */
    public static java.util.Currency toJavaCurrency(Currency currency) {
        return java.util.Currency.getInstance(currency.getCode());
    }

}