com.cumulocity.model.util
Class ExtensibilityConverter

java.lang.Object
  extended by com.cumulocity.model.util.ExtensibilityConverter

public class ExtensibilityConverter
extends Object

Converts between Java types and JSON according to the extensibility naming rules.


Nested Class Summary
protected static class ExtensibilityConverter.ClassFinder
           
 
Constructor Summary
ExtensibilityConverter()
           
 
Method Summary
static Class classFromExtensibilityString(String name)
          Converts the given name into a class using the extensibility rules where underscores are converted to dots ("_" => ".").
 Class classFromExtensibilityString2(String name)
           
static
<T> String
classToStringRepresentation(Class<T> clazz)
          Returns a string representation of the canonical name of the given class but with dots (".") replaced with underscores ("_").
<T> String
classToStringRepresentation2(Class<T> clazz)
           
static Enum enumFromExtensibilityString(String name)
          Converts the given name into an enum using the extensibility rules where underscores are converted to dots ("_" => ".").
 Enum enumFromExtensibilityString2(String name)
           
static String extensibleEnumToStringRepresentation(ExtensibleEnum e)
          Returns a string representation of the given extensible enum but with dots (".") in the class name replaced with underscores ("_").
 String extensibleEnumToStringRepresentation2(ExtensibleEnum e)
           
protected static ExtensibilityConverter getInstance()
           
protected  void setClassFinder(ExtensibilityConverter.ClassFinder classFinder)
           
protected static void setInstance(ExtensibilityConverter instance)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtensibilityConverter

public ExtensibilityConverter()
Method Detail

setClassFinder

protected void setClassFinder(ExtensibilityConverter.ClassFinder classFinder)

setInstance

protected static void setInstance(ExtensibilityConverter instance)

getInstance

protected static ExtensibilityConverter getInstance()

classFromExtensibilityString

public static Class classFromExtensibilityString(String name)
                                          throws ClassNotFoundException
Converts the given name into a class using the extensibility rules where underscores are converted to dots ("_" => "."). For example:
name = "com_cumulocity_model_idtype_Reference" would return the class com.cumulocity.mode.idtype.Reference

Throws:
ClassNotFoundException - if the name cannot be converted to a class using the extensibility rules

classFromExtensibilityString2

public Class classFromExtensibilityString2(String name)
                                    throws ClassNotFoundException
Throws:
ClassNotFoundException

classToStringRepresentation

public static <T> String classToStringRepresentation(Class<T> clazz)
Returns a string representation of the canonical name of the given class but with dots (".") replaced with underscores ("_"). Useful for creating JSON property names from class names.


classToStringRepresentation2

public <T> String classToStringRepresentation2(Class<T> clazz)

enumFromExtensibilityString

public static Enum enumFromExtensibilityString(String name)
                                        throws ClassNotFoundException,
                                               IllegalArgumentException
Converts the given name into an enum using the extensibility rules where underscores are converted to dots ("_" => "."). For example:
name = "com_cumulocity_model_event_DefaultAlarmStatuses.ACTIVE" would return the enum value com.cumulocity.model.event.DefaultAlarmStatuses.ACTIVE

Throws:
ClassNotFoundException - if the enum class cannot be found
IllegalArgumentException - if the value does not exist in the enum

enumFromExtensibilityString2

public Enum enumFromExtensibilityString2(String name)
                                  throws ClassNotFoundException,
                                         IllegalArgumentException
Throws:
ClassNotFoundException
IllegalArgumentException

extensibleEnumToStringRepresentation

public static String extensibleEnumToStringRepresentation(ExtensibleEnum e)
Returns a string representation of the given extensible enum but with dots (".") in the class name replaced with underscores ("_"). For example:
com.othercorp.statuses.SOMESTATUS => "com_othercorp_statuses.SOMESTATUS" Useful for creating JSON property names from enums.


extensibleEnumToStringRepresentation2

public String extensibleEnumToStringRepresentation2(ExtensibleEnum e)


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