DealLink.java

package com.tradecloud.domain.model;

import com.tradecloud.common.base.PersistenceBase;
import com.tradecloud.domain.common.Percentage;
import com.tradecloud.domain.model.deal.Deal;

import javax.persistence.*;
import java.io.Serializable;

/**
 * Base class that encapsulates common deal link fields.
 *
 * @see FECDealLink
 * @see FECRequestDealLink
 */
@MappedSuperclass
public abstract class DealLink extends PersistenceBase implements Serializable {

    private static final long serialVersionUID = 1L;

    @ManyToOne(fetch = FetchType.EAGER, optional = false)
    protected Deal deal;

    @Embedded
    @AttributeOverrides({@AttributeOverride(name = "currency", column = @Column(name = "amount_currency")),
            @AttributeOverride(name = "value", column = @Column(name = "amount_value", precision = 19, scale = 6))})
    protected Money amount;

    @Embedded
    protected Percentage percentage;

    /**
     * This constructor is for Hibernate use only.
     */
    public DealLink() {
    }

    public DealLink(Deal deal, Money amount, Percentage percentage) {
        this.deal = deal;
        this.amount = amount;
        this.percentage = percentage;
    }

    public Deal getDeal() {
        return deal;
    }

    public void setDeal(Deal deal) {
        this.deal = deal;
    }

    public Money getAmount() {
        return amount;
    }

    public void setAmount(Money amount) {
        this.amount = amount;
    }

    public Percentage getPercentage() {
        return percentage;
    }

    public void setPercentage(Percentage percentage) {
        this.percentage = percentage;
    }
}