Class ValueSnakImpl

java.lang.Object
org.wikidata.wdtk.datamodel.implementation.SnakImpl
org.wikidata.wdtk.datamodel.implementation.ValueSnakImpl
All Implemented Interfaces:
Snak, ValueSnak

public class ValueSnakImpl extends SnakImpl implements ValueSnak
Jackson implementation of ValueSnak.
Author:
Fredo Erxleben, Antonin Delpeuch
  • Constructor Details

    • ValueSnakImpl

      public ValueSnakImpl(PropertyIdValue property, Value value)
      Constructor.
      Parameters:
      property - the id of the property used in this snak
      value - the target value for this snak
    • ValueSnakImpl

      protected ValueSnakImpl(String property, String datatype, Value datavalue, String siteIri)
      Constructor used to deserialize from JSON with Jackson.
  • Method Details

    • getDatavalue

      public Value getDatavalue()
    • getValue

      public Value getValue()
      Description copied from interface: ValueSnak
      Get the Value of this Snak
      Specified by:
      getValue in interface ValueSnak
    • getDatatype

      public String getDatatype()
      Returns the JSON datatype string. Only for use by Jackson during serialization. The property datatype of the property used for this value snak. This is redundant information provided in the JSON but not represented in the datamodel. We keep it and serialize it if given, but if we do not have it, we set it to null and it will be omitted in the serialization.
      Returns:
      the JSON datatype string
    • getSnakType

      public String getSnakType()
      Specified by:
      getSnakType in class SnakImpl
    • accept

      public <T> T accept(SnakVisitor<T> snakVisitor)
      Description copied from interface: Snak
      Accept a SnakVisitor and return its output.
      Specified by:
      accept in interface Snak
      Parameters:
      snakVisitor - the SnakVisitor
      Returns:
      output of the visitor
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getJsonPropertyTypeForValueType

      protected static String getJsonPropertyTypeForValueType(Value value)
      Infer the JSON datatype (represented as a string) from the data value.
      Parameters:
      value - the datavalue used as snak value
      Returns:
      the JSON type (possibly null) to include in the serialization of the snak