Class CurieConverter
- All Implemented Interfaces:
IConverter
This is especially intended for slots of type uriOrCurie. The
converter will automatically expand the CURIE upon deserialising the data, so
that after parsing we no longer need to worry about the presence of CURIEs
anywhere – there will only be full-length IRIs. Conversely, when serialising
the data the converter will take care of compacting the IRIs back into CURIE
form.
This is basically a generalisation of the approach previously used specifically for SSSOM-Java: expand CURIEs as soon as possible upon receiving data, contract them as late as possible upon writing data. In between, you only need to deal with full-length IRIs. This is the only sane way of working with CURIEs.
Note: This class would normally belong to the
org.incenp.linkml.core.converters package, along with all other
IConverter implementations. But LinkML-Py’s Java generator used to
assume that CurieConverter was in the core package
instead, so for backwards compatibility it has to remain here.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectconvertImpl(Object raw, ConverterContext ctx) Performs the actual type conversion.getURI()Gets the URI identifying the LinkML type this converter is intended for.serialise(Object object, ConverterContext ctx) Converts a LinkML object into a raw object.Methods inherited from class StringConverter
getTypeMethods inherited from class ScalarConverterBase
convert, convertForSlot, serialiseForSlot, toList
-
Field Details
-
URIORCURIE_TYPE_URI
- See Also:
-
-
Constructor Details
-
CurieConverter
public CurieConverter()
-
-
Method Details
-
getURI
Description copied from interface:IConverterGets the URI identifying the LinkML type this converter is intended for.This is intended to provide another way to look up converter objects, if looking up by the Java type (using
IConverter.getType()) is not enough (typically, when several LinkML types are rendered using the same Java type).- Returns:
- The LinkML type URI. May be
null.
-
convertImpl
Description copied from class:ScalarConverterBasePerforms the actual type conversion.- Overrides:
convertImplin classStringConverter- Parameters:
raw- The raw object to convert. This is guaranteed to be a non-null, non-list, non-dictionary object.- Returns:
- The converted value.
- Throws:
LinkMLRuntimeException- If the converter cannot convert the given value.
-
serialise
Description copied from interface:IConverterConverts a LinkML object into a raw object.Given the Java representation of a LinkML object, this method shall return an object suitable to be given to a generic JSON/YAML writer.
- Specified by:
serialisein interfaceIConverter- Overrides:
serialisein classScalarConverterBase- Parameters:
object- The LinkML object to convert.ctx- The global converter context.- Returns:
- The raw object that represents the original LinkML object.
- Throws:
LinkMLRuntimeException- If the converter cannot convert the given object.
-