Class LexemeUpdateBuilder


public class LexemeUpdateBuilder extends StatementDocumentUpdateBuilder
Builder for incremental construction of LexemeUpdate objects.
  • Method Details

    • forBaseRevisionId

      public static LexemeUpdateBuilder forBaseRevisionId(LexemeIdValue lexemeId, long revisionId)
      Creates new builder object for constructing update of lexeme entity with given revision ID.
      Parameters:
      lexemeId - ID of the lexeme that is to be updated
      revisionId - ID of the base lexeme revision to be updated or zero if not available
      Returns:
      update builder object
      Throws:
      NullPointerException - if lexemeId is null
      IllegalArgumentException - if lexemeId is a placeholder ID
    • forEntityId

      public static LexemeUpdateBuilder forEntityId(LexemeIdValue lexemeId)
      Creates new builder object for constructing update of lexeme entity with given ID.
      Parameters:
      lexemeId - ID of the lexeme that is to be updated
      Returns:
      update builder object
      Throws:
      NullPointerException - if lexemeId is null
      IllegalArgumentException - if lexemeId is a placeholder ID
    • forBaseRevision

      public static LexemeUpdateBuilder forBaseRevision(LexemeDocument revision)
      Creates new builder object for constructing update of given base lexeme entity revision. Provided lexeme document might not represent the latest revision of the lexeme entity as currently stored in Wikibase. It will be used for validation in builder methods. If the document has revision ID, it will be used to detect edit conflicts.
      Parameters:
      revision - base lexeme entity revision to be updated
      Returns:
      update builder object
      Throws:
      NullPointerException - if revision is null
      IllegalArgumentException - if revision has placeholder ID
    • updateStatements

      public LexemeUpdateBuilder updateStatements(StatementUpdate update)
      Description copied from class: StatementDocumentUpdateBuilder
      Updates entity statements. If this method is called multiple times, changes are accumulated. If base entity revision was provided, the update is checked against it and redundant changes are silently ignored, resulting in empty update.
      Overrides:
      updateStatements in class StatementDocumentUpdateBuilder
      Parameters:
      update - statement update, possibly empty
      Returns:
      this (fluent method)
    • setLanguage

      public LexemeUpdateBuilder setLanguage(ItemIdValue language)
      Sets lexeme language. If base entity revision was provided, attempt to replace lexeme language with the same value is silently ignored, resulting in empty update.
      Parameters:
      language - new lexeme language
      Returns:
      this (fluent method)
      Throws:
      NullPointerException - if language is null
      IllegalArgumentException - if language is an invalid ID
    • setLexicalCategory

      public LexemeUpdateBuilder setLexicalCategory(ItemIdValue category)
      Sets lexical category of the lexeme. If base entity revision was provided, attempt to replace lexical category with the same value is silently ignored, resulting in empty update.
      Parameters:
      category - new lexical category
      Returns:
      this (fluent method)
      Throws:
      NullPointerException - if category is null
      IllegalArgumentException - if category is an invalid ID
    • updateLemmas

      public LexemeUpdateBuilder updateLemmas(TermUpdate update)
      Updates lemmas. If this method is called multiple times, changes are accumulated. If base entity revision was provided, redundant changes are silently ignored, resulting in empty update.
      Parameters:
      update - changes in lemmas
      Returns:
      this (fluent method)
      Throws:
      NullPointerException - if update is null
    • addSense

      public LexemeUpdateBuilder addSense(SenseDocument sense)
      Adds sense to the lexeme. If sense has an ID (perhaps because it is a modified copy of another sense), its ID is stripped to ensure the sense is added and no other sense is modified.
      Parameters:
      sense - new sense to add
      Returns:
      this (fluent method)
      Throws:
      NullPointerException - if sense is null
    • updateSense

      public LexemeUpdateBuilder updateSense(SenseUpdate update)
      Updates existing sense in the lexeme. If this method is called multiple times, changes are accumulated. If base entity revision was provided, the update is checked against it and redundant changes are silently ignored, resulting in empty update.
      Parameters:
      update - update of existing sense
      Returns:
      this (fluent method)
      Throws:
      NullPointerException - if update is null
      IllegalArgumentException - if the sense does not exist in base revision (if available) or the update cannot be applied to it
      IllegalStateException - if the sense was removed by calling removeSense(SenseIdValue)
    • removeSense

      public LexemeUpdateBuilder removeSense(SenseIdValue senseId)
      Removes existing sense from the lexeme. Removing the same sense ID twice is silently tolerated. Any prior changes made by calling updateSense(SenseUpdate) are discarded.
      Parameters:
      senseId - ID of the removed sense
      Returns:
      this (fluent method)
      Throws:
      NullPointerException - if senseId is null
      IllegalArgumentException - if senseId is not valid or if such ID does not exist in base revision (if available)
    • addForm

      public LexemeUpdateBuilder addForm(FormDocument form)
      Adds form to the lexeme. If form has an ID (perhaps because it is a modified copy of another form), its ID is stripped to ensure the form is added and no other form is modified.
      Parameters:
      form - new form to add
      Returns:
      this (fluent method)
      Throws:
      NullPointerException - if form is null
    • updateForm

      public LexemeUpdateBuilder updateForm(FormUpdate update)
      Updates existing form in the lexeme. If this method is called multiple times, changes are accumulated. If base entity revision was provided, the update is checked against it and redundant changes are silently ignored, resulting in empty update.
      Parameters:
      update - update of existing form
      Returns:
      this (fluent method)
      Throws:
      NullPointerException - if update is null
      IllegalArgumentException - if the form does not exist in base revision (if available) or the update cannot be applied to it
      IllegalStateException - if the form was removed by calling removeForm(FormIdValue)
    • removeForm

      public LexemeUpdateBuilder removeForm(FormIdValue formId)
      Removes existing form from the lexeme. Calling this method overrides any previous changes made to the same form ID by updateForm(FormUpdate). Removing the same form ID twice is silently tolerated.
      Parameters:
      formId - ID of the removed form
      Returns:
      this (fluent method)
      Throws:
      NullPointerException - if formId is null
      IllegalArgumentException - if formId is not valid or if such ID does not exist in current version of the lexeme document (if available)
    • append

      public LexemeUpdateBuilder append(LexemeUpdate update)
      Replays all changes in provided update into this builder object. Changes from the update are added on top of changes already present in this builder object.
      Parameters:
      update - lexeme update to replay
      Returns:
      this (fluent method)
      Throws:
      NullPointerException - if update is null
      IllegalArgumentException - if update cannot be applied to base entity revision (if available)
    • build

      public LexemeUpdate build()
      Description copied from class: StatementDocumentUpdateBuilder
      Creates new StatementDocumentUpdate object with contents of this builder object.
      Specified by:
      build in class StatementDocumentUpdateBuilder
      Returns:
      constructed object