2017-10-27 16:43:26 +02:00
|
|
|
package org.gcube.datacatalogue.common.enums;
|
|
|
|
|
2018-02-26 19:01:05 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2017-10-27 16:43:26 +02:00
|
|
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonValue;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stock types
|
|
|
|
* @author Costantino Perciante at ISTI-CNR
|
|
|
|
* (costantino.perciante@isti.cnr.it)
|
|
|
|
*/
|
|
|
|
public enum Stock_Type {
|
|
|
|
|
|
|
|
Assessment_Unit("Assessment Unit"),
|
|
|
|
Marine_Resource("Marine Resource");
|
|
|
|
|
|
|
|
private String subGroupNameOrig;
|
|
|
|
|
|
|
|
private Stock_Type(String origName) {
|
|
|
|
this.subGroupNameOrig = origName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the original name
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String getOrigName(){
|
|
|
|
return subGroupNameOrig;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the json value
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@JsonValue
|
|
|
|
public String onSerialize(){
|
|
|
|
return subGroupNameOrig.toLowerCase();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get back an enum from json string
|
|
|
|
* @param typeString
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@JsonCreator
|
|
|
|
public static Stock_Type onDeserialize(String typeString) {
|
|
|
|
if(typeString != null) {
|
|
|
|
for(Stock_Type type : Stock_Type.values()) {
|
|
|
|
if(type.getOrigName().equalsIgnoreCase(typeString.trim().toLowerCase()) || type.getOrigName().toLowerCase().contains(typeString.trim().toLowerCase()))
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used by reflection
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return getOrigName();
|
|
|
|
}
|
2018-02-26 19:01:05 +01:00
|
|
|
|
|
|
|
public static List<String> getTypesAsListString(){
|
|
|
|
List<String> toReturn = new ArrayList<String>(Stock_Type.values().length);
|
|
|
|
for(Stock_Type type : Stock_Type.values())
|
|
|
|
toReturn.add(type.getOrigName());
|
|
|
|
return toReturn;
|
|
|
|
}
|
2017-10-27 16:43:26 +02:00
|
|
|
|
|
|
|
}
|