Class StatementImpl

java.lang.Object
org.wikidata.wdtk.datamodel.implementation.StatementImpl
All Implemented Interfaces:
Statement

public class StatementImpl extends Object implements Statement
Jackson implementation of Statement. In JSON, the corresponding structures are referred to as "claim".
Author:
Fredo Erxleben, Antonin Delpeuch, Thomas Pellissier Tanon
  • Constructor Details

    • StatementImpl

      public StatementImpl(String statementId, StatementRank rank, Snak mainSnak, List<SnakGroup> qualifiers, List<Reference> references, EntityIdValue subjectId)
      Constructor.

      The statementId is used mainly for communication with a Wikibase site, in order to refer to statements of that site. When creating new statements that are not on any site, the empty string can be used.

      Parameters:
      statementId - the string id of the Statement: can be empty if the statement has not obtained it yet
      rank - the rank of the Statement
      mainSnak - the main snak for the Claim of the Statement
      qualifiers - the snak groups for the qualifiers
      references - the references for the Statement
      subjectId - the subject of this Statement
    • StatementImpl

      public StatementImpl(String statementId, StatementRank rank, Snak mainSnak, Map<String,List<Snak>> qualifiers, List<String> qualifiersOrder, List<Reference> references, EntityIdValue subjectId)
    • StatementImpl

      public StatementImpl(String statementId, Snak mainsnak, EntityIdValue subjectId)
      TODO review the utility of this constructor.
  • Method Details

    • getClaim

      public Claim getClaim()
      Description copied from interface: Statement
      Get the Claim object that this statement refers to.
      Specified by:
      getClaim in interface Statement
      Returns:
      the claim that this statement refers to
    • getSubject

      public EntityIdValue getSubject()
      Description copied from interface: Statement
      The subject that the claim refers to, e.g., the id of "Berlin".
      Specified by:
      getSubject in interface Statement
      Returns:
      EntityId of the subject
    • getMainSnak

      public Snak getMainSnak()
      Description copied from interface: Statement
      Main Snak of the statement. This Snak refers directly to the subject, e.g., the ValueSnak "Population: 3000000".
      Specified by:
      getMainSnak in interface Statement
      Returns:
      the main snak
    • getQualifiers

      public List<SnakGroup> getQualifiers()
      Description copied from interface: Statement
      Groups of auxiliary Snaks, also known as qualifiers, that provide additional context information for this claim. For example, "as of: 2014" might be a temporal context given for a claim that provides a population number. The snaks are grouped by the property that they use.
      Specified by:
      getQualifiers in interface Statement
      Returns:
      list of snak groups
    • getAllQualifiers

      public Iterator<Snak> getAllQualifiers()
      Description copied from interface: Statement
      Returns an iterator over all qualifiers, without considering qualifier groups. The relative order of qualifiers is preserved.
      Specified by:
      getAllQualifiers in interface Statement
      Returns:
      iterator over all qualifier snaks
    • getRank

      public StatementRank getRank()
      Specified by:
      getRank in interface Statement
      Returns:
      the rank of the Statement
      See Also:
    • getReferences

      public List<Reference> getReferences()
      Description copied from interface: Statement
      Get a list of references for this Statement. Each reference is represented by a list of Snaks, which provide information about the reference.
      Specified by:
      getReferences in interface Statement
      Returns:
      the list of references
    • getStatementId

      public String getStatementId()
      Description copied from interface: Statement
      Return the id used to identify this statement.

      Statement ids are used by Wikibase to allow certain interactions though the API, especially the atomic modification of Statements (modifications of statements can be viewed as deletions followed by insertions, but doing this in several steps though the API is not practical). In the current Wikibase implementation, the id is a string that begins with the (sometimes lowercased) local ID of the subject of the statement, followed by a dollar sign and a randomly generated UUID. Thus statements of different subjects can never have the same id, and it is extremely unlikely that two statements of the one subject ever have the same id. However, it is possible that two statements with the same content differ in their id, since the id is not based on the content.

      Wikidata Toolkit generally requires ids to be specified but you can use the empty string to indicate that a statement has no id. This will also be respected when serializing data as JSON, i.e., rather than setting the statement id to an empty string in JSON, the key will simply be omitted. This is useful for creating new statements through the API.

      Callers should not make any assumptions about the stability of statement ids over time, or about the internal format of the ids.

      Specified by:
      getStatementId in interface Statement
      Returns:
      the statement string id
    • getValue

      public Value getValue()
      Description copied from interface: Statement
      Convenience method to get the value of the statement's claim's main snak, or null if there is none.
      Specified by:
      getValue in interface Statement
      Returns:
      main value of the statement, or null
    • withStatementId

      public Statement withStatementId(String id)
      Description copied from interface: Statement
      Returns the same statement, but with a different identifier. This is useful when the existing identifier was empty and we need to attribute one before creating the statement in a remote Wikibase instance.
      Specified by:
      withStatementId in interface Statement
    • 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