Class TransparentConverter
- All Implemented Interfaces:
IConverter
This converter is especially intended to deal with slots whose range is set
to linkml:Any (or, more precisely, to a class that “takes the
role of linkml:Any”), which are represented in Java as
Object-typed fields. The value of a such a field does not require any
conversion (and in fact attempting to convert one using the generic
ObjectConverter would lead to an error).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvert(Object raw, ConverterContext ctx) Converts a raw object into a LinkML object.voidconvertForSlot(Object raw, Object dest, Slot slot, ConverterContext ctx) Converts a raw object into a LinkML object and assigns the result to a slot of another object.Class<?> getType()Gets the type of object that this converter can convert a raw object into.serialise(Object object, ConverterContext ctx) Converts a LinkML object into a raw object.serialiseForSlot(Object object, Slot slot, ConverterContext ctx) Converts a LinkML object into a raw object, when the object is the value of a specific LinkML slot.
-
Constructor Details
-
TransparentConverter
public TransparentConverter()
-
-
Method Details
-
getType
Description copied from interface:IConverterGets the type of object that this converter can convert a raw object into.- Specified by:
getTypein interfaceIConverter- Returns:
- The Java type representing the LinkML object this converter is intended for.
-
convert
Description copied from interface:IConverterConverts a raw object into a LinkML object.Given the raw representation of a LinkML object, as it may have been obtained from a generic JSON/YAML parser, this method shall return a suitable Java representation of the object.
- Specified by:
convertin interfaceIConverter- Parameters:
raw- The raw object to convert.ctx- The global converter context.- Returns:
- The converted object.
- Throws:
LinkMLRuntimeException- If the converter cannot convert the given value.
-
convertForSlot
public void convertForSlot(Object raw, Object dest, Slot slot, ConverterContext ctx) throws LinkMLRuntimeException Description copied from interface:IConverterConverts a raw object into a LinkML object and assigns the result to a slot of another object.In principle, calling this method shall perform the equivalent of the following code:
slot.setValue(dest, convert(raw, ctx));
but sometimes, an object of a given type may have to be deserialised differently depending on the slot it is intended to be assigned to. Converter implementations shall then perform whatever is necessary in this method for converting an object for a given slot.
- Specified by:
convertForSlotin interfaceIConverter- Parameters:
raw- The raw object to convert.dest- The object that should received the converted value.slot- The slot of thedestobject to which the converted value should be assigned.ctx- The global converter context.- Throws:
LinkMLRuntimeException- If the converter cannot convert the given value, or cannot assign it to the target object/slot.
-
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- 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.
-
serialiseForSlot
public Object serialiseForSlot(Object object, Slot slot, ConverterContext ctx) throws LinkMLRuntimeException Description copied from interface:IConverterConverts a LinkML object into a raw object, when the object is the value of a specific LinkML slot.We need such a method because the way to serialise a LinkML object into a raw object will sometimes depend on the slot to which the object belongs (the slot of which it is a value), especially with respect to inlining.
- Specified by:
serialiseForSlotin interfaceIConverter- Parameters:
object- The LinkML object to convert.slot- The slot that the given object is a value of.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.
-
toList
-