com.algoTrader.vo.BarVO.java Source code

Java tutorial

Introduction

Here is the source code for com.algoTrader.vo.BarVO.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::BarVO
 * STEREOTYPE:   ValueObject
 */
package com.algoTrader.vo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
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 BarVO
 */
public class BarVO implements Serializable, Comparable<BarVO> {
    /** The serial version UID of this class. Needed for serialization. */
    private static final long serialVersionUID = -6214877150001818745L;

    // Class attributes
    /** TODO: Model Documentation for attribute isin */
    protected String isin;
    /** TODO: Model Documentation for attribute dateTime */
    protected Date dateTime;
    /** TODO: Model Documentation for attribute open */
    protected BigDecimal open;
    /** TODO: Model Documentation for attribute high */
    protected BigDecimal high;
    /** TODO: Model Documentation for attribute low */
    protected BigDecimal low;
    /** TODO: Model Documentation for attribute close */
    protected BigDecimal close;
    /** TODO: Model Documentation for attribute adjClose */
    protected BigDecimal adjClose;
    /** TODO: Model Documentation for attribute vol */
    protected int vol;
    /**
     * boolean setter for primitive attribute, so we can tell if it's initialized
     */
    protected boolean setVol = false;
    /** TODO: Model Documentation for attribute openInterest */
    protected int openInterest;
    /**
     * boolean setter for primitive attribute, so we can tell if it's initialized
     */
    protected boolean setOpenInterest = false;

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

    /**
     * Constructor taking only required properties
     * @param isinIn String
     * @param dateTimeIn Date
     * @param openIn BigDecimal
     * @param highIn BigDecimal
     * @param lowIn BigDecimal
     * @param closeIn BigDecimal
     * @param volIn int
     * @param openInterestIn int
     */
    public BarVO(final String isinIn, final Date dateTimeIn, final BigDecimal openIn, final BigDecimal highIn,
            final BigDecimal lowIn, final BigDecimal closeIn, final int volIn, final int openInterestIn) {
        this.isin = isinIn;
        this.dateTime = dateTimeIn;
        this.open = openIn;
        this.high = highIn;
        this.low = lowIn;
        this.close = closeIn;
        this.vol = volIn;
        this.setVol = true;
        this.openInterest = openInterestIn;
        this.setOpenInterest = true;
    }

    /**
     * Constructor with all properties
     * @param isinIn String
     * @param dateTimeIn Date
     * @param openIn BigDecimal
     * @param highIn BigDecimal
     * @param lowIn BigDecimal
     * @param closeIn BigDecimal
     * @param adjCloseIn BigDecimal
     * @param volIn int
     * @param openInterestIn int
     */
    public BarVO(final String isinIn, final Date dateTimeIn, final BigDecimal openIn, final BigDecimal highIn,
            final BigDecimal lowIn, final BigDecimal closeIn, final BigDecimal adjCloseIn, final int volIn,
            final int openInterestIn) {
        this.isin = isinIn;
        this.dateTime = dateTimeIn;
        this.open = openIn;
        this.high = highIn;
        this.low = lowIn;
        this.close = closeIn;
        this.adjClose = adjCloseIn;
        this.vol = volIn;
        this.setVol = true;
        this.openInterest = openInterestIn;
        this.setOpenInterest = true;
    }

    /**
     * Copies constructor from other BarVO
     *
     * @param otherBean Cannot be <code>null</code>
     * @throws NullPointerException if the argument is <code>null</code>
     */
    public BarVO(final BarVO otherBean) {
        this.isin = otherBean.getIsin();
        this.dateTime = otherBean.getDateTime();
        this.open = otherBean.getOpen();
        this.high = otherBean.getHigh();
        this.low = otherBean.getLow();
        this.close = otherBean.getClose();
        this.adjClose = otherBean.getAdjClose();
        this.vol = otherBean.getVol();
        this.setVol = true;
        this.openInterest = otherBean.getOpenInterest();
        this.setOpenInterest = true;
    }

    /**
     * Copies all properties from the argument value object into this value object.
     * @param otherBean Cannot be <code>null</code>
     */
    public void copy(final BarVO otherBean) {
        if (null != otherBean) {
            this.setIsin(otherBean.getIsin());
            this.setDateTime(otherBean.getDateTime());
            this.setOpen(otherBean.getOpen());
            this.setHigh(otherBean.getHigh());
            this.setLow(otherBean.getLow());
            this.setClose(otherBean.getClose());
            this.setAdjClose(otherBean.getAdjClose());
            this.setVol(otherBean.getVol());
            this.setVol = true;
            this.setOpenInterest(otherBean.getOpenInterest());
            this.setOpenInterest = true;
        }
    }

    /**
     * TODO: Model Documentation for attribute isin
     * Get the isin Attribute
     * @return isin String
     */
    public String getIsin() {
        return this.isin;
    }

    /**
     * 
     * @param value String
     */
    public void setIsin(final String value) {
        this.isin = value;
    }

    /**
     * TODO: Model Documentation for attribute dateTime
     * Get the dateTime Attribute
     * @return dateTime Date
     */
    public Date getDateTime() {
        return this.dateTime;
    }

    /**
     * 
     * @param value Date
     */
    public void setDateTime(final Date value) {
        this.dateTime = value;
    }

    /**
     * TODO: Model Documentation for attribute open
     * Get the open Attribute
     * @return open BigDecimal
     */
    public BigDecimal getOpen() {
        return this.open;
    }

    /**
     * 
     * @param value BigDecimal
     */
    public void setOpen(final BigDecimal value) {
        this.open = value;
    }

    /**
     * TODO: Model Documentation for attribute high
     * Get the high Attribute
     * @return high BigDecimal
     */
    public BigDecimal getHigh() {
        return this.high;
    }

    /**
     * 
     * @param value BigDecimal
     */
    public void setHigh(final BigDecimal value) {
        this.high = value;
    }

    /**
     * TODO: Model Documentation for attribute low
     * Get the low Attribute
     * @return low BigDecimal
     */
    public BigDecimal getLow() {
        return this.low;
    }

    /**
     * 
     * @param value BigDecimal
     */
    public void setLow(final BigDecimal value) {
        this.low = value;
    }

    /**
     * TODO: Model Documentation for attribute close
     * Get the close Attribute
     * @return close BigDecimal
     */
    public BigDecimal getClose() {
        return this.close;
    }

    /**
     * 
     * @param value BigDecimal
     */
    public void setClose(final BigDecimal value) {
        this.close = value;
    }

    /**
     * TODO: Model Documentation for attribute adjClose
     * Get the adjClose Attribute
     * @return adjClose BigDecimal
     */
    public BigDecimal getAdjClose() {
        return this.adjClose;
    }

    /**
     * 
     * @param value BigDecimal
     */
    public void setAdjClose(final BigDecimal value) {
        this.adjClose = value;
    }

    /**
     * TODO: Model Documentation for attribute vol
     * Get the vol Attribute
     * @return vol int
     */
    public int getVol() {
        return this.vol;
    }

    /**
     * 
     * @param value int
     */
    public void setVol(final int value) {
        this.vol = value;
        this.setVol = true;
    }

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

    /**
     * TODO: Model Documentation for attribute openInterest
     * Get the openInterest Attribute
     * @return openInterest int
     */
    public int getOpenInterest() {
        return this.openInterest;
    }

    /**
     * 
     * @param value int
     */
    public void setOpenInterest(final int value) {
        this.openInterest = value;
        this.setOpenInterest = true;
    }

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

    /**
     * @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;
        }
        BarVO rhs = (BarVO) object;
        return new EqualsBuilder().append(this.getIsin(), rhs.getIsin())
                .append(this.getDateTime(), rhs.getDateTime()).append(this.getOpen(), rhs.getOpen())
                .append(this.getHigh(), rhs.getHigh()).append(this.getLow(), rhs.getLow())
                .append(this.getClose(), rhs.getClose()).append(this.getAdjClose(), rhs.getAdjClose())
                .append(this.getVol(), rhs.getVol()).append(this.getOpenInterest(), rhs.getOpenInterest())
                .isEquals();
    }

    /**
     * @param object to compare this object against
     * @return int if equal
     * @see Comparable#compareTo(Object)
     */
    public int compareTo(final BarVO object) {
        if (object == null) {
            return -1;
        }
        // Check if the same object instance
        if (object == this) {
            return 0;
        }
        return new CompareToBuilder().append(this.getIsin(), object.getIsin())
                .append(this.getDateTime(), object.getDateTime()).append(this.getOpen(), object.getOpen())
                .append(this.getHigh(), object.getHigh()).append(this.getLow(), object.getLow())
                .append(this.getClose(), object.getClose()).append(this.getAdjClose(), object.getAdjClose())
                .append(this.getVol(), object.getVol()).append(this.getOpenInterest(), object.getOpenInterest())
                .toComparison();
    }

    /**
     * @return int hashCode value
     * @see Object#hashCode()
     */
    @Override
    public int hashCode() {
        return new HashCodeBuilder(1249046965, -82296885).append(this.getIsin()).append(this.getDateTime())
                .append(this.getOpen()).append(this.getHigh()).append(this.getLow()).append(this.getClose())
                .append(this.getAdjClose()).append(this.getVol()).append(this.getOpenInterest()).toHashCode();
    }

    /**
     * @return String representation of object
     * @see Object#toString()
     */
    @Override
    public String toString() {
        return new ToStringBuilder(this).append("isin", this.getIsin()).append("dateTime", this.getDateTime())
                .append("open", this.getOpen()).append("high", this.getHigh()).append("low", this.getLow())
                .append("close", this.getClose()).append("adjClose", this.getAdjClose())
                .append("vol", this.getVol()).append("openInterest", this.getOpenInterest()).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 BarVO that = (BarVO) thatObject;

        return equal(this.getIsin(), that.getIsin()) && equal(this.getDateTime(), that.getDateTime())
                && equal(this.getOpen(), that.getOpen()) && equal(this.getHigh(), that.getHigh())
                && equal(this.getLow(), that.getLow()) && equal(this.getClose(), that.getClose())
                && equal(this.getAdjClose(), that.getAdjClose()) && equal(this.getVol(), that.getVol())
                && equal(this.getOpenInterest(), that.getOpenInterest());
    }

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

    // BarVO value-object java merge-point
}