Class SlotExtractor<T>
java.lang.Object
org.incenp.obofoundry.sssom.slots.SlotVisitorBase<T>
org.incenp.obofoundry.sssom.extract.SlotExtractor<T>
- Type Parameters:
T
- The type of object from which to extract a slot value (MappingSet
orMapping
).
- All Implemented Interfaces:
ISlotVisitor<T>
Common logic used by both the
MappingSetSlotExtractor
and the
MappingSlotExtractor
classes.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSlotExtractor
(Slot<T> slot) Creates a new instance.SlotExtractor
(Slot<T> slot, int itemNo) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptiongetSlotValue
(T object) Performs the actual extraction.Class
<?> getType()
Returns the type of the extracted value.void
Visits a generic slot.void
Visits a multi-valued string-typed slot.
-
Field Details
-
slot
-
itemNo
protected int itemNo
-
-
Constructor Details
-
SlotExtractor
Creates a new instance.If the slot is a multi-valued slot, this will extract the first value.
- Parameters:
slot
- The slot to extract.
-
SlotExtractor
Creates a new instance.- Parameters:
slot
- The slot to extract.itemNo
- The 0-based index of the value to extract, or (if negative) the 1-based index starting from the last value. This is only meaningful for a multi-valued slot.
-
-
Method Details
-
getSlotValue
Performs the actual extraction.- Parameters:
object
- The object from which to extract the slot value.- Returns:
- The extract value, or
null
if the object does not have a value at the specified location.
-
getType
Returns the type of the extracted value.- Returns:
- The type of the value that would be returned by
getSlotValue(Object)
.
-
visit
Description copied from interface:ISlotVisitor
Visits a generic slot.This method is normally not used as all slots in a SSSOM object have more precise types. But it can be used to implement behaviours that should be common to several slot types.
- Specified by:
visit
in interfaceISlotVisitor<T>
- Overrides:
visit
in classSlotVisitorBase<T>
- Parameters:
slot
- The slot that is being visited.object
- The object to which the slot is attached.value
- The value of the slot.
-
visit
Description copied from interface:ISlotVisitor
Visits a multi-valued string-typed slot.- Specified by:
visit
in interfaceISlotVisitor<T>
- Overrides:
visit
in classSlotVisitorBase<T>
- Parameters:
slot
- The slot that is being visited.object
- The object to which the slot is attached.values
- The values of the slot.
-