Class TermUpdateBuilder

java.lang.Object
org.wikidata.wdtk.datamodel.helpers.TermUpdateBuilder

public class TermUpdateBuilder extends Object
Builder for incremental construction of TermUpdate objects.
  • Method Details

    • create

      public static TermUpdateBuilder create()
      Creates new builder object for constructing term update.
      Returns:
      update builder object
    • forTerms

      public static TermUpdateBuilder forTerms(Collection<MonolingualTextValue> terms)
      Creates new builder object for constructing update of given base revision terms. Provided terms will be used to check correctness of changes.

      Since all changes will be checked after the TermUpdate is passed to EntityUpdateBuilder anyway, it is usually unnecessary to use this method. It is simpler to initialize the builder with create().

      Parameters:
      terms - terms from base revision of the document
      Returns:
      update builder object
      Throws:
      NullPointerException - if terms or any of its items is null
      IllegalArgumentException - if there are duplicate items in terms
    • put

      Adds or changes term. If a term with this language code already exists, it is replaced. Terms with other language codes are not touched. Calling this method overrides any previous changes made with the same language code by this method or remove(String).

      If base revision terms were provided, attempt to overwrite some term with the same value will be silently ignored, resulting in empty update.

      Parameters:
      term - term to add or change
      Returns:
      this (fluent method)
      Throws:
      NullPointerException - if term is null
    • remove

      public TermUpdateBuilder remove(String languageCode)
      Removes term. Terms with other language codes are not touched. Calling this method overrides any previous changes made with the same language code by this method or put(MonolingualTextValue).

      If base revision terms were provided, attempts to remove missing terms will be silently ignored, resulting in empty update.

      Parameters:
      languageCode - language code of the removed term
      Returns:
      this (fluent method)
      Throws:
      NullPointerException - if languageCode is null
      IllegalArgumentException - if languageCode is blank
    • append

      public TermUpdateBuilder append(TermUpdate update)
      Replays all changes in provided update into this builder object. Changes are performed as if by calling put(MonolingualTextValue) and remove(String) methods.
      Parameters:
      update - term update to replay
      Returns:
      this (fluent method)
      Throws:
      NullPointerException - if update is null
    • build

      public TermUpdate build()
      Creates new TermUpdate object with contents of this builder object.
      Returns:
      constructed object