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 or Mapping).
All Implemented Interfaces:
ISlotVisitor<T>

public class SlotExtractor<T> extends SlotVisitorBase<T>
Common logic used by both the MappingSetSlotExtractor and the MappingSlotExtractor classes.
  • Field Details

    • slot

      protected Slot<T> slot
    • itemNo

      protected int itemNo
  • Constructor Details

    • SlotExtractor

      public SlotExtractor(Slot<T> slot)
      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

      public SlotExtractor(Slot<T> slot, int itemNo)
      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

      public Object getSlotValue(T object)
      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

      public Class<?> getType()
      Returns the type of the extracted value.
      Returns:
      The type of the value that would be returned by getSlotValue(Object).
    • visit

      public void visit(Slot<T> slot, T object, Object value)
      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 interface ISlotVisitor<T>
      Overrides:
      visit in class SlotVisitorBase<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

      public void visit(StringSlot<T> slot, T object, List<String> values)
      Description copied from interface: ISlotVisitor
      Visits a multi-valued string-typed slot.
      Specified by:
      visit in interface ISlotVisitor<T>
      Overrides:
      visit in class SlotVisitorBase<T>
      Parameters:
      slot - The slot that is being visited.
      object - The object to which the slot is attached.
      values - The values of the slot.