/*
* Copyright (c) 2014-2015 Red Hat, Inc. and/or its affiliates.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Cheng Fang - Initial API and implementation
*/
package org.jberet.support.io;
import java.util.Date;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
/**
* Extends {@link StockTradeBase} with a {@code java.util.Date} field that is configured with {@code JsonFormat}.
*/
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY,
getterVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.NONE)
@JsonPropertyOrder({"Date", "Time", "Open", "High", "Low", "Close", "Volume"})
public class StockTrade2 extends StockTradeBase {
private static final long serialVersionUID = 671273522774714965L;
@NotNull
@Past
@JsonProperty("Date")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy")
Date date;
public Date getDate() {
return date;
}
public void setDate(final Date date) {
this.date = date;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("StockTrade{");
sb.append("date=").append(date);
sb.append(", time='").append(time).append('\'');
sb.append(", open=").append(open);
sb.append(", high=").append(high);
sb.append(", low=").append(low);
sb.append(", close=").append(close);
sb.append(", volume=").append(volume);
sb.append('}');
return sb.toString();
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (!(o instanceof StockTrade2)) return false;
final StockTrade2 that = (StockTrade2) o;
if (Double.compare(that.close, close) != 0) return false;
if (Double.compare(that.high, high) != 0) return false;
if (Double.compare(that.low, low) != 0) return false;
if (Double.compare(that.open, open) != 0) return false;
if (Double.compare(that.volume, volume) != 0) return false;
if (!date.equals(that.date)) return false;
if (!time.equals(that.time)) return false;
return true;
}
@Override
public int hashCode() {
int result;
long temp;
result = date.hashCode();
result = 31 * result + time.hashCode();
temp = Double.doubleToLongBits(open);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(high);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(low);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(close);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(volume);
result = 31 * result + (int) (temp ^ (temp >>> 32));
return result;
}
}