com.cumulocity.model.event
Class SeverityConverter

java.lang.Object
  extended by com.cumulocity.model.event.SeverityConverter
All Implemented Interfaces:
org.svenson.converter.TypeConverter

public class SeverityConverter
extends Object
implements org.svenson.converter.TypeConverter

Converts event severities to and from JSON. When converting to JSON the class name will be included in the value using the core model extensibility naming rules unless the instance is of type CumulocitySeverities or the status in which case just the value is written. For example:

 com.othercorp.severities.SOMESEVERITY => "com_othercorp_severities.SOMESEVERITY"
 com.cumulocity.model.event.CumulocitySeverities.CRITICAL => "CRITICAL"
 
When converting from JSON the converter will look for a type using the core model extensibility naming convention. If the type is found then an instance of that class is returned, if there is no type but the name is one of the CumulocitySeverities then an instance of DefaultSevertities is returned, otherwise an instance of com.cumulocity.model.event.SeverityImpl is returned. For example:
 "com_othercorp_severities.SOMESEVERITY" => com.othercorp.severities.SOMESEVERITY (assuming com.othercorp.severities is known)
 "CRITICAL" => com.cumulocity.model.event.CumulocitySeverities.CRITICAL
 "SOMESEVERITY" => com.cumulocity.model.event.SeverityImpl
 


Constructor Summary
SeverityConverter()
           
 
Method Summary
 Object fromJSON(Object in)
           
 Object toJSON(Object in)
          Converts Severity to JSON.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SeverityConverter

public SeverityConverter()
Method Detail

fromJSON

public Object fromJSON(Object in)
Specified by:
fromJSON in interface org.svenson.converter.TypeConverter

toJSON

public Object toJSON(Object in)
Converts Severity to JSON. If the passed object is one of the CumulocitySeverities then simply the name is returned, otherwise the class name is converted using the extensibility naming convention, for example:
com.cumulocity.model.event.DefaultAlarmStatuses.ACTIVE => "ACTIVE" com.othercorp.enums.ENUM => "com_othercorp_enums.ENUM"

Specified by:
toJSON in interface org.svenson.converter.TypeConverter


Copyright © 2013 (C) Cumulocity GmbH. All Rights Reserved.