com.algoTrader.vo.PortfolioValueVO.java Source code

Java tutorial

Introduction

Here is the source code for com.algoTrader.vo.PortfolioValueVO.java

Source

// license-header java merge-point
//
/**
 * @author Generated on 02/10/2014 17:30:59+0000 Do not modify by hand!
 *
 * TEMPLATE:     ValueObject.vsl in andromda-java-cartridge.
 * MODEL CLASS:  Data::AlgoTrader::com.algoTrader::vo::PortfolioValueVO
 * STEREOTYPE:   ValueObject
 */
package com.algoTrader.vo;

import java.io.Serializable;
import java.util.Arrays;
import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * TODO: Model Documentation for class PortfolioValueVO
 */
public class PortfolioValueVO implements Serializable, Comparable<PortfolioValueVO> {
    /** The serial version UID of this class. Needed for serialization. */
    private static final long serialVersionUID = -1239053325328896278L;

    // Class attributes
    /** TODO: Model Documentation for attribute securitiesCurrentValue */
    protected double securitiesCurrentValue;
    /**
     * boolean setter for primitive attribute, so we can tell if it's initialized
     */
    protected boolean setSecuritiesCurrentValue = false;
    /** TODO: Model Documentation for attribute cashBalance */
    protected double cashBalance;
    /**
     * boolean setter for primitive attribute, so we can tell if it's initialized
     */
    protected boolean setCashBalance = false;
    /** TODO: Model Documentation for attribute maintenanceMargin */
    protected double maintenanceMargin;
    /**
     * boolean setter for primitive attribute, so we can tell if it's initialized
     */
    protected boolean setMaintenanceMargin = false;
    /** TODO: Model Documentation for attribute netLiqValue */
    protected double netLiqValue;
    /**
     * boolean setter for primitive attribute, so we can tell if it's initialized
     */
    protected boolean setNetLiqValue = false;

    /** Default Constructor with no properties */
    public PortfolioValueVO() {
        // Documented empty block - avoid compiler warning - no super constructor
    }

    /**
     * Constructor with all properties
     * @param securitiesCurrentValueIn double
     * @param cashBalanceIn double
     * @param maintenanceMarginIn double
     * @param netLiqValueIn double
     */
    public PortfolioValueVO(final double securitiesCurrentValueIn, final double cashBalanceIn,
            final double maintenanceMarginIn, final double netLiqValueIn) {
        this.securitiesCurrentValue = securitiesCurrentValueIn;
        this.setSecuritiesCurrentValue = true;
        this.cashBalance = cashBalanceIn;
        this.setCashBalance = true;
        this.maintenanceMargin = maintenanceMarginIn;
        this.setMaintenanceMargin = true;
        this.netLiqValue = netLiqValueIn;
        this.setNetLiqValue = true;
    }

    /**
     * Copies constructor from other PortfolioValueVO
     *
     * @param otherBean Cannot be <code>null</code>
     * @throws NullPointerException if the argument is <code>null</code>
     */
    public PortfolioValueVO(final PortfolioValueVO otherBean) {
        this.securitiesCurrentValue = otherBean.getSecuritiesCurrentValue();
        this.setSecuritiesCurrentValue = true;
        this.cashBalance = otherBean.getCashBalance();
        this.setCashBalance = true;
        this.maintenanceMargin = otherBean.getMaintenanceMargin();
        this.setMaintenanceMargin = true;
        this.netLiqValue = otherBean.getNetLiqValue();
        this.setNetLiqValue = true;
    }

    /**
     * Copies all properties from the argument value object into this value object.
     * @param otherBean Cannot be <code>null</code>
     */
    public void copy(final PortfolioValueVO otherBean) {
        if (null != otherBean) {
            this.setSecuritiesCurrentValue(otherBean.getSecuritiesCurrentValue());
            this.setSecuritiesCurrentValue = true;
            this.setCashBalance(otherBean.getCashBalance());
            this.setCashBalance = true;
            this.setMaintenanceMargin(otherBean.getMaintenanceMargin());
            this.setMaintenanceMargin = true;
            this.setNetLiqValue(otherBean.getNetLiqValue());
            this.setNetLiqValue = true;
        }
    }

    /**
     * TODO: Model Documentation for attribute securitiesCurrentValue
     * Get the securitiesCurrentValue Attribute
     * @return securitiesCurrentValue double
     */
    public double getSecuritiesCurrentValue() {
        return this.securitiesCurrentValue;
    }

    /**
     * 
     * @param value double
     */
    public void setSecuritiesCurrentValue(final double value) {
        this.securitiesCurrentValue = value;
        this.setSecuritiesCurrentValue = true;
    }

    /**
     * Return true if the primitive attribute securitiesCurrentValue is set, through the setter or constructor
     * @return true if the attribute value has been set
     */
    public boolean isSetSecuritiesCurrentValue() {
        return this.setSecuritiesCurrentValue;
    }

    /**
     * TODO: Model Documentation for attribute cashBalance
     * Get the cashBalance Attribute
     * @return cashBalance double
     */
    public double getCashBalance() {
        return this.cashBalance;
    }

    /**
     * 
     * @param value double
     */
    public void setCashBalance(final double value) {
        this.cashBalance = value;
        this.setCashBalance = true;
    }

    /**
     * Return true if the primitive attribute cashBalance is set, through the setter or constructor
     * @return true if the attribute value has been set
     */
    public boolean isSetCashBalance() {
        return this.setCashBalance;
    }

    /**
     * TODO: Model Documentation for attribute maintenanceMargin
     * Get the maintenanceMargin Attribute
     * @return maintenanceMargin double
     */
    public double getMaintenanceMargin() {
        return this.maintenanceMargin;
    }

    /**
     * 
     * @param value double
     */
    public void setMaintenanceMargin(final double value) {
        this.maintenanceMargin = value;
        this.setMaintenanceMargin = true;
    }

    /**
     * Return true if the primitive attribute maintenanceMargin is set, through the setter or constructor
     * @return true if the attribute value has been set
     */
    public boolean isSetMaintenanceMargin() {
        return this.setMaintenanceMargin;
    }

    /**
     * TODO: Model Documentation for attribute netLiqValue
     * Get the netLiqValue Attribute
     * @return netLiqValue double
     */
    public double getNetLiqValue() {
        return this.netLiqValue;
    }

    /**
     * 
     * @param value double
     */
    public void setNetLiqValue(final double value) {
        this.netLiqValue = value;
        this.setNetLiqValue = true;
    }

    /**
     * Return true if the primitive attribute netLiqValue is set, through the setter or constructor
     * @return true if the attribute value has been set
     */
    public boolean isSetNetLiqValue() {
        return this.setNetLiqValue;
    }

    /**
     * @param object to compare this object against
     * @return boolean if equal
     * @see Object#equals(Object)
     */
    @Override
    public boolean equals(final Object object) {
        if (object == null || object.getClass() != this.getClass()) {
            return false;
        }
        // Check if the same object instance
        if (object == this) {
            return true;
        }
        PortfolioValueVO rhs = (PortfolioValueVO) object;
        return new EqualsBuilder().append(this.getSecuritiesCurrentValue(), rhs.getSecuritiesCurrentValue())
                .append(this.getCashBalance(), rhs.getCashBalance())
                .append(this.getMaintenanceMargin(), rhs.getMaintenanceMargin())
                .append(this.getNetLiqValue(), rhs.getNetLiqValue()).isEquals();
    }

    /**
     * @param object to compare this object against
     * @return int if equal
     * @see Comparable#compareTo(Object)
     */
    public int compareTo(final PortfolioValueVO object) {
        if (object == null) {
            return -1;
        }
        // Check if the same object instance
        if (object == this) {
            return 0;
        }
        return new CompareToBuilder().append(this.getSecuritiesCurrentValue(), object.getSecuritiesCurrentValue())
                .append(this.getCashBalance(), object.getCashBalance())
                .append(this.getMaintenanceMargin(), object.getMaintenanceMargin())
                .append(this.getNetLiqValue(), object.getNetLiqValue()).toComparison();
    }

    /**
     * @return int hashCode value
     * @see Object#hashCode()
     */
    @Override
    public int hashCode() {
        return new HashCodeBuilder(1249046965, -82296885).append(this.getSecuritiesCurrentValue())
                .append(this.getCashBalance()).append(this.getMaintenanceMargin()).append(this.getNetLiqValue())
                .toHashCode();
    }

    /**
     * @return String representation of object
     * @see Object#toString()
     */
    @Override
    public String toString() {
        return new ToStringBuilder(this).append("securitiesCurrentValue", this.getSecuritiesCurrentValue())
                .append("cashBalance", this.getCashBalance())
                .append("maintenanceMargin", this.getMaintenanceMargin())
                .append("netLiqValue", this.getNetLiqValue()).toString();
    }

    /**
     * Compares the properties of this instance to the properties of the argument. This method will return
     * {@code false} as soon as it detects that the argument is {@code null} or not of the same type as
     * (or a sub-type of) this instance's type.
     *
     * <p/>For array, collection or map properties the comparison will be done one level deep, in other words:
     * the elements will be compared using the {@code equals()} operation.
     *
     * <p/>Note that two properties will be considered equal when both values are {@code null}.
     *
     * @param thatObject the object containing the properties to compare against this instance
     * @return this method will return {@code true} in case the argument has the same type as this class, or is a
     *      sub-type of this class and all properties as found on this class have equal values when queried on that
     *      argument instance; in all other cases this method will return {@code false}
     */
    public boolean equalProperties(final Object thatObject) {
        if (thatObject == null || !this.getClass().isAssignableFrom(thatObject.getClass())) {
            return false;
        }

        final PortfolioValueVO that = (PortfolioValueVO) thatObject;

        return equal(this.getSecuritiesCurrentValue(), that.getSecuritiesCurrentValue())
                && equal(this.getCashBalance(), that.getCashBalance())
                && equal(this.getMaintenanceMargin(), that.getMaintenanceMargin())
                && equal(this.getNetLiqValue(), that.getNetLiqValue());
    }

    /**
     * This is a convenient helper method which is able to detect whether or not two values are equal. Two values
     * are equal when they are both {@code null}, are arrays of the same length with equal elements or are
     * equal objects (this includes {@link java.util.Collection} and {@link java.util.Map} instances).
     *
     * <p/>Note that for array, collection or map instances the comparison runs one level deep.
     *
     * @param first the first object to compare, may be {@code null}
     * @param second the second object to compare, may be {@code null}
     * @return this method will return {@code true} in case both objects are equal as explained above;
     *      in all other cases this method will return {@code false}
     */
    protected static boolean equal(final Object first, final Object second) {
        final boolean equal;

        if (first == null) {
            equal = (second == null);
        } else if (first.getClass().isArray() && (second != null) && second.getClass().isArray()) {
            equal = Arrays.equals((Object[]) first, (Object[]) second);
        } else // note that the following also covers java.util.Collection and java.util.Map
        {
            equal = first.equals(second);
        }

        return equal;
    }

    // PortfolioValueVO value-object java merge-point
}