Class TypeMapper
- java.lang.Object
-
- org.gcube.informationsystem.types.TypeMapper
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.gcube.com.fasterxml.jackson.databind.ObjectMappermapperThe object mapper.
-
Constructor Summary
Constructors Constructor Description TypeMapper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <E extends Element>
TypecreateTypeDefinition(Class<E> clz)static TypedeserializeTypeDefinition(String json)Deserializes aTypedefinition from a JSON string.static List<Type>deserializeTypeDefinitions(String json)Deserializes a list ofTypedefinitions from a JSON string.static <E extends Element,EImpl extends E>
Class<EImpl>getDynamicImplementation(Class<E> clz)Gets the dynamic implementation class for a given interface, if specified via theDeserializeannotation.static <E extends Element>
StringgetType(E e)Returns the type name of anElementinstance.static StringgetType(Class<? extends Element> clz)Returns the type name of anElementclass, derived from annotations.static Map<Version,String>getTypeChangelog(Class<? extends Element> clz)static StringgetTypeDescription(Class<? extends Element> clz)Returns the description of anElementclass from itsTypeMetadata.static VersiongetTypeVersion(Class<? extends Element> clz)Returns the version of anElementclass from itsTypeMetadata.static <E extends Element>
StringserializeType(Class<E> clz)static StringserializeTypeDefinition(Type type)Serializes aTypedefinition to a JSON string.static StringserializeTypeDefinitions(List<Type> typeDefinitions)Serializes a list ofTypedefinitions to a JSON string.
-
-
-
Method Detail
-
serializeTypeDefinition
public static String serializeTypeDefinition(Type type) throws Exception
Serializes aTypedefinition to a JSON string.- Parameters:
type- The type definition.- Returns:
- The JSON string.
- Throws:
Exception- if an error occurs during serialization.
-
deserializeTypeDefinition
public static Type deserializeTypeDefinition(String json) throws Exception
Deserializes aTypedefinition from a JSON string.- Parameters:
json- The JSON string.- Returns:
- The deserialized type definition.
- Throws:
Exception- if an error occurs during deserialization.
-
serializeTypeDefinitions
public static String serializeTypeDefinitions(List<Type> typeDefinitions) throws Exception
Serializes a list ofTypedefinitions to a JSON string.- Parameters:
typeDefinitions- The list of type definitions.- Returns:
- The JSON string.
- Throws:
Exception- if an error occurs during serialization.
-
deserializeTypeDefinitions
public static List<Type> deserializeTypeDefinitions(String json) throws Exception
Deserializes a list ofTypedefinitions from a JSON string.- Parameters:
json- The JSON string.- Returns:
- The deserialized list of type definitions.
- Throws:
Exception- if an error occurs during deserialization.
-
createTypeDefinition
public static <E extends Element> Type createTypeDefinition(Class<E> clz)
- Type Parameters:
E- The type of the element.- Parameters:
clz- The element class.- Returns:
- The generated type definition.
-
serializeType
public static <E extends Element> String serializeType(Class<E> clz) throws Exception
- Type Parameters:
E- The type of the element.- Parameters:
clz- The element class.- Returns:
- The JSON string representation of the type.
- Throws:
Exception- if an error occurs during serialization.
-
getType
public static <E extends Element> String getType(E e)
Returns the type name of anElementinstance.- Type Parameters:
E- The type of the element.- Parameters:
e- The element instance.- Returns:
- The type name.
-
getDynamicImplementation
public static <E extends Element,EImpl extends E> Class<EImpl> getDynamicImplementation(Class<E> clz)
Gets the dynamic implementation class for a given interface, if specified via theDeserializeannotation.- Type Parameters:
E- The type of the element.EImpl- The type of the implementation.- Parameters:
clz- The interface class.- Returns:
- The implementation class, or
null.
-
getType
public static String getType(Class<? extends Element> clz)
Returns the type name of anElementclass, derived from annotations.- Parameters:
clz- The element class.- Returns:
- The type name.
-
getTypeDescription
public static String getTypeDescription(Class<? extends Element> clz)
Returns the description of anElementclass from itsTypeMetadata.- Parameters:
clz- The element class.- Returns:
- The type description.
-
getTypeVersion
public static Version getTypeVersion(Class<? extends Element> clz)
Returns the version of anElementclass from itsTypeMetadata.- Parameters:
clz- The element class.- Returns:
- The type version.
-
-