com.algoTrader.vo.PerformanceKeysVO.java Source code

Java tutorial

Introduction

Here is the source code for com.algoTrader.vo.PerformanceKeysVO.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::PerformanceKeysVO
 * 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 PerformanceKeysVO
 */
public class PerformanceKeysVO implements Serializable, Comparable<PerformanceKeysVO> {
    /** The serial version UID of this class. Needed for serialization. */
    private static final long serialVersionUID = -170154156953289350L;

    // Class attributes
    /** TODO: Model Documentation for attribute n */
    protected long n;
    /**
     * boolean setter for primitive attribute, so we can tell if it's initialized
     */
    protected boolean setN = false;
    /** TODO: Model Documentation for attribute avgM */
    protected double avgM;
    /**
     * boolean setter for primitive attribute, so we can tell if it's initialized
     */
    protected boolean setAvgM = false;
    /** TODO: Model Documentation for attribute stdM */
    protected double stdM;
    /**
     * boolean setter for primitive attribute, so we can tell if it's initialized
     */
    protected boolean setStdM = false;
    /** TODO: Model Documentation for attribute avgY */
    protected double avgY;
    /**
     * boolean setter for primitive attribute, so we can tell if it's initialized
     */
    protected boolean setAvgY = false;
    /** TODO: Model Documentation for attribute stdY */
    protected double stdY;
    /**
     * boolean setter for primitive attribute, so we can tell if it's initialized
     */
    protected boolean setStdY = false;
    /** TODO: Model Documentation for attribute sharpRatio */
    protected double sharpRatio;
    /**
     * boolean setter for primitive attribute, so we can tell if it's initialized
     */
    protected boolean setSharpRatio = false;

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

    /**
     * Constructor with all properties
     * @param nIn long
     * @param avgMIn double
     * @param stdMIn double
     * @param avgYIn double
     * @param stdYIn double
     * @param sharpRatioIn double
     */
    public PerformanceKeysVO(final long nIn, final double avgMIn, final double stdMIn, final double avgYIn,
            final double stdYIn, final double sharpRatioIn) {
        this.n = nIn;
        this.setN = true;
        this.avgM = avgMIn;
        this.setAvgM = true;
        this.stdM = stdMIn;
        this.setStdM = true;
        this.avgY = avgYIn;
        this.setAvgY = true;
        this.stdY = stdYIn;
        this.setStdY = true;
        this.sharpRatio = sharpRatioIn;
        this.setSharpRatio = true;
    }

    /**
     * Copies constructor from other PerformanceKeysVO
     *
     * @param otherBean Cannot be <code>null</code>
     * @throws NullPointerException if the argument is <code>null</code>
     */
    public PerformanceKeysVO(final PerformanceKeysVO otherBean) {
        this.n = otherBean.getN();
        this.setN = true;
        this.avgM = otherBean.getAvgM();
        this.setAvgM = true;
        this.stdM = otherBean.getStdM();
        this.setStdM = true;
        this.avgY = otherBean.getAvgY();
        this.setAvgY = true;
        this.stdY = otherBean.getStdY();
        this.setStdY = true;
        this.sharpRatio = otherBean.getSharpRatio();
        this.setSharpRatio = true;
    }

    /**
     * Copies all properties from the argument value object into this value object.
     * @param otherBean Cannot be <code>null</code>
     */
    public void copy(final PerformanceKeysVO otherBean) {
        if (null != otherBean) {
            this.setN(otherBean.getN());
            this.setN = true;
            this.setAvgM(otherBean.getAvgM());
            this.setAvgM = true;
            this.setStdM(otherBean.getStdM());
            this.setStdM = true;
            this.setAvgY(otherBean.getAvgY());
            this.setAvgY = true;
            this.setStdY(otherBean.getStdY());
            this.setStdY = true;
            this.setSharpRatio(otherBean.getSharpRatio());
            this.setSharpRatio = true;
        }
    }

    /**
     * TODO: Model Documentation for attribute n
     * Get the n Attribute
     * @return n long
     */
    public long getN() {
        return this.n;
    }

    /**
     * 
     * @param value long
     */
    public void setN(final long value) {
        this.n = value;
        this.setN = true;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @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;
        }
        PerformanceKeysVO rhs = (PerformanceKeysVO) object;
        return new EqualsBuilder().append(this.getN(), rhs.getN()).append(this.getAvgM(), rhs.getAvgM())
                .append(this.getStdM(), rhs.getStdM()).append(this.getAvgY(), rhs.getAvgY())
                .append(this.getStdY(), rhs.getStdY()).append(this.getSharpRatio(), rhs.getSharpRatio()).isEquals();
    }

    /**
     * @param object to compare this object against
     * @return int if equal
     * @see Comparable#compareTo(Object)
     */
    public int compareTo(final PerformanceKeysVO object) {
        if (object == null) {
            return -1;
        }
        // Check if the same object instance
        if (object == this) {
            return 0;
        }
        return new CompareToBuilder().append(this.getN(), object.getN()).append(this.getAvgM(), object.getAvgM())
                .append(this.getStdM(), object.getStdM()).append(this.getAvgY(), object.getAvgY())
                .append(this.getStdY(), object.getStdY()).append(this.getSharpRatio(), object.getSharpRatio())
                .toComparison();
    }

    /**
     * @return int hashCode value
     * @see Object#hashCode()
     */
    @Override
    public int hashCode() {
        return new HashCodeBuilder(1249046965, -82296885).append(this.getN()).append(this.getAvgM())
                .append(this.getStdM()).append(this.getAvgY()).append(this.getStdY()).append(this.getSharpRatio())
                .toHashCode();
    }

    /**
     * @return String representation of object
     * @see Object#toString()
     */
    @Override
    public String toString() {
        return new ToStringBuilder(this).append("n", this.getN()).append("avgM", this.getAvgM())
                .append("stdM", this.getStdM()).append("avgY", this.getAvgY()).append("stdY", this.getStdY())
                .append("sharpRatio", this.getSharpRatio()).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 PerformanceKeysVO that = (PerformanceKeysVO) thatObject;

        return equal(this.getN(), that.getN()) && equal(this.getAvgM(), that.getAvgM())
                && equal(this.getStdM(), that.getStdM()) && equal(this.getAvgY(), that.getAvgY())
                && equal(this.getStdY(), that.getStdY()) && equal(this.getSharpRatio(), that.getSharpRatio());
    }

    /**
     * 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;
    }

    // PerformanceKeysVO value-object java merge-point
}