Class Slot<T>
- java.lang.Object
-
- org.incenp.obofoundry.sssom.slots.Slot<T>
-
- Type Parameters:
T- The type of SSSOM object (e.g. Mapping, MappingSet, etc.).
- Direct Known Subclasses:
CurieMapSlot,DateSlot,DoubleSlot,EntityTypeSlot,ExtensionDefinitionSlot,ExtensionSlot,MappingCardinalitySlot,PredicateModifierSlot,StringSlot,VersionSlot
public class Slot<T> extends Object
Represents a metadata slot on a SSSOM object.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <V> Vaccept(ISimpleSlotVisitor<T,V> visitor, T target, Object value)Accepts a simple visitor.voidaccept(ISlotVisitor<T> visitor, T target, Object value)Accepts a visitor.VersiongetCompliantVersion()Gets the earliest version of the SSSOM specification this slot is compatible with.StringgetName()Gets the name of the slot as it appears in the SSSOM specification (e.g.,mapping_justification,subject_id, etc.).Class<?>getType()Gets the underlying Java type for the slot.StringgetURI()Gets the URI of the slot.ObjectgetValue(T object)Gets the value of the slot for a given object.booleanisEntityReference()Indicates whether the slot is intended to hold an entity reference.booleanisPropagatable()Indicates whether the slot is a "propagatable slot".booleanisURI()Indicates whether the slot is expected to contain a URI.voidsetValue(T object, Object value)Sets the value of the slot for a given object.voidsetValue(T object, String value)Tries setting the value of the slot for a given object, using a string as input.
-
-
-
Method Detail
-
getName
public String getName()
Gets the name of the slot as it appears in the SSSOM specification (e.g.,mapping_justification,subject_id, etc.).- Returns:
- The slot name as per the SSSOM specification, independently of the implementation.
-
getURI
public String getURI()
Gets the URI of the slot.For most slots, this is simply the slot’s name appended to the SSSOM IRI prefix (e.g.
https://w3id.org/sssom/subject_label), but some slots use a URI borrowed from another specification instead (for example, the URI for thecreator_idishttp://purl.org/dc/terms/creator).- Returns:
- The URI associated with the slot.
-
isEntityReference
public boolean isEntityReference()
Indicates whether the slot is intended to hold an entity reference. Entity references are represented as strings but need to be treated differently.- Returns:
trueis the slot is intended to hold an entity reference, otherwisefalse.
-
isPropagatable
public boolean isPropagatable()
Indicates whether the slot is a "propagatable slot".- Returns:
trueif the slot can be propagated, otherwisefalse.
-
isURI
public boolean isURI()
Indicates whether the slot is expected to contain a URI.- Returns:
trueif the slot is defined as having a URI range, otherwisefalse.
-
getCompliantVersion
public Version getCompliantVersion()
Gets the earliest version of the SSSOM specification this slot is compatible with. This is the version in which the slot was first introduced.- Returns:
- The earliest compatible SSSOM version.
-
getType
public Class<?> getType()
Gets the underlying Java type for the slot.- Returns:
- The Java data type used to store the slot's data.
-
accept
public void accept(ISlotVisitor<T> visitor, T target, Object value)
Accepts a visitor.- Parameters:
visitor- The visitor to accept.target- The object this slot is attached to.value- The value of the slot.
-
accept
public <V> V accept(ISimpleSlotVisitor<T,V> visitor, T target, Object value)
Accepts a simple visitor. A “simple” visitor is one that does not distinguish between the different types of slots, i.e. the same method is used to visit all slots.- Type Parameters:
V- The type of object returned by the visitor.- Parameters:
visitor- The visitor to accept.target- The object this slot is attached to.value- The value of the slot.- Returns:
- The valued returned by the visitor.
-
getValue
public Object getValue(T object)
Gets the value of the slot for a given object.- Parameters:
object- The object (e.g. a mapping or a mapping set) from which to retrieve the value.- Returns:
- The value of the slot in that object.
-
setValue
public void setValue(T object, Object value)
Sets the value of the slot for a given object.- Parameters:
object- The object (e.g. a mapping or a mapping set) for which the slot should be set.value- The value to assign to the slot on the given object.
-
setValue
public void setValue(T object, String value)
Tries setting the value of the slot for a given object, using a string as input.This method only works for String-typed slots, but classes for other slot types can override it to allow parsing a string into another type of value.
- Parameters:
object- The object (e.g. a mapping or a mapping set) for which the slot should be set.value- The value to assign to the slot on the given object.- Throws:
UnsupportedOperationException- When this method is called on a slot that is not string-typed.
-
-