71 lines
1.6 KiB
Java
71 lines
1.6 KiB
Java
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 <year, value>
|
|
* @author Costantino Perciante at ISTI-CNR
|
|
* (costantino.perciante@isti.cnr.it)
|
|
*/
|
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
public class TimeSeriesBean<T> {
|
|
|
|
@JsonProperty("value")
|
|
@NotNull(message="value of a time series cannot be null")
|
|
private T value;
|
|
|
|
@JsonProperty("year")
|
|
@NotNull(message="year of a time series cannot be null")
|
|
private Long year;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public TimeSeriesBean() {
|
|
super();
|
|
}
|
|
/**
|
|
* @param value
|
|
* @param year
|
|
*/
|
|
public TimeSeriesBean(T value, Long year) {
|
|
super();
|
|
this.value = value;
|
|
this.year = year;
|
|
}
|
|
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;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
|
|
Class<? extends Object> 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
|
|
return "TimeSeriesBean [value=" + value + ", year=" + year + "]";
|
|
}
|
|
|
|
}
|