if( !(o instanceof Threshold) ) {
throw new SerializationException("ThresholdJSONSerializer is unable to serialize object of type: " + o.getClass().getName());
}
try {
Threshold thr = (Threshold)o;
result = new JSONObject();
result.put(THRESHOLD_ID, thr.getId() );
result.put(THRESHOLD_NAME, thr.getName() );
result.put(THRESHOLD_DESCRIPTION, thr.getDescription() );
result.put(THRESHOLD_CODE, thr.getCode() );
result.put(THRESHOLD_TYPE_ID, thr.getThresholdTypeId() );
result.put(THRESHOLD_TYPE_CD, thr.getThresholdTypeCode());
result.put(OLD_TO_DELETE, new Boolean(false));
List thrValues = thr.getThresholdValues();
JSONArray thValues = new JSONArray();
if(thrValues!=null){
if(!thrValues.isEmpty()){
if(thrValues.size()==1 && !thr.getThresholdTypeCode().equalsIgnoreCase("RANGE")){
ThresholdValue thrVal = (ThresholdValue) thrValues.get(0);
if(thrVal != null){
result.put(THR_VAL_ID, thrVal.getId());
result.put(THR_VAL_LABEL, thrVal.getLabel());
result.put(THR_VAL_POSITION, thrVal.getPosition());