Class ClassDefinitionConverter
- java.lang.Object
-
- org.incenp.linkml.core.ObjectConverter
-
- org.incenp.linkml.schema.ClassDefinitionConverter
-
- All Implemented Interfaces:
IConverter
public class ClassDefinitionConverter extends ObjectConverter
A converter object specifically intended to convertClassDefinitionobjects.We need a subclass for
ClassDefinitionobjects because class definitions purposefully violate the unicity constraint of theSlotDefinitionclass. A slot definition is supposed to be a unique object (only one object with the same name can exist in the global context). But several classes can have an attribute with the same name, that should not imply that they share the same attribute! (In fact, one of the reasons for the concept of attributes is precisely so that classes can have “local slots” – slots whose definition has no impact outside of the declaring class. Therefore, within a LinkML schema, there may very well be severalSlotDefinitionobjects with the same name: one global slot at most, plus an arbitrary number of class-specific attributes.In LinkML-Py, this violation of the unicity constraint is apparently managed by prepending the name of the declaring class to the name of the attribute, as in
class__slotname, so that all slot definitions (including definitions of class-specific attributes) are globally unique.The approach adopted here is simply not to put the attribute definitions in the global context at all, so that they are really specific to the class in which they are defined. But this requires overriding the default behaviour of the
ObjectConverter, which puts all unique objects (that is, all instances of classes that have an identifier slot) in the global context.Likewise for the
SlotDefinitionobjects found in theslot_usagesection: they are really local to the class and should not be treated as global objects.
-
-
Field Summary
-
Fields inherited from class org.incenp.linkml.core.ObjectConverter
klass
-
-
Constructor Summary
Constructors Constructor Description ClassDefinitionConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconvertTo(Map<String,Object> rawMap, Object dest, ConverterContext ctx)Converts a raw map into an instance of a LinkML object, where the object already exists.-
Methods inherited from class org.incenp.linkml.core.ObjectConverter
convert, convert, convert, convertForSlot, convertTo, getGlobalIdentifier, getGlobalIdentifierList, getType, normaliseList, serialise, serialise, serialiseForSlot, toIdentifier, toList, toMap
-
-
-
-
Method Detail
-
convertTo
public void convertTo(Map<String,Object> rawMap, Object dest, ConverterContext ctx) throws LinkMLRuntimeException
Description copied from class:ObjectConverterConverts a raw map into an instance of a LinkML object, where the object already exists.- Overrides:
convertToin classObjectConverter- Parameters:
rawMap- The raw map to convert.dest- The instance of the LinkML object whose slots should be filled with values from the raw map.ctx- The global converter context.- Throws:
LinkMLRuntimeException- If a slot of thedestobject cannot be assigned.
-
-