package org.gcube.data_catalogue.grsf_publish_ws.json.input; import javax.validation.constraints.NotNull; import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Abundance_Level; import org.gcube.data_catalogue.grsf_publish_ws.utils.groups.Exploitation_Rate; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; /** * A time series bean that contains couple * Catches_and_landings contains also Unit * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) */ @JsonIgnoreProperties(ignoreUnknown = true) public class TimeSeriesBean implements Comparable>{ @JsonProperty("year") @NotNull(message="year of a time series cannot be null") private Long year; @JsonProperty("value") @NotNull(message="value of a time series cannot be null") private T value; @JsonProperty("unit") private T1 unit; public TimeSeriesBean() { super(); } public TimeSeriesBean(T value, Long year, T1 unit) { super(); this.value = value; this.year = year; this.unit = unit; } public T getValue() { return value; } public void setValue(T value) { this.value = value; } public Long getYear() { return year; } public void setYear(Long year) { this.year = year; } public T1 getUnit() { return unit; } public void setUnit(T1 unit) { this.unit = unit; } @Override public String toString() { Class valueClass = value.getClass(); // when the value belongs to these classes annotated with @Tag.. if(valueClass.equals(Abundance_Level.class) || valueClass.equals(Exploitation_Rate.class)) return year + "-" + value; else if(this.unit != null && this.unit.getClass().equals(String.class)) // catches and landings return year + "-" + value + "-" + unit; else return "TimeSeriesBean [value=" + value + ", unit=" + unit + ", year=" + year + "]"; } @Override public int compareTo(TimeSeriesBean o) { return (int) (this.year - o.year); // ascending.. low to highest } }