Class AliasUpdateBuilder

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

public class AliasUpdateBuilder extends Object
Builder for incremental construction of AliasUpdate objects.
  • Method Details

    • create

      public static AliasUpdateBuilder create()
      Creates new builder object for constructing alias update.
      Returns:
      update builder object
    • forAliases

      public static AliasUpdateBuilder forAliases(List<MonolingualTextValue> aliases)
      Creates new builder object for constructing update of given base revision aliases. Provided aliases will be used to check correctness of changes.

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

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

      Adds new alias. This operation can be repeated to add multiple aliases in one update. It can be combined with remove(MonolingualTextValue). Attempt to add the same alias twice or to add alias already present in base document (if available) is silently ignored. Adding previously removed alias cancels the removal. If recreate(List) was called before, this method will add the alias to the end of the new alias list.
      Parameters:
      alias - new alias
      Returns:
      this (fluent method)
      Throws:
      NullPointerException - if alias is null
      IllegalArgumentException - if the alias has language code inconsistent with other aliases
    • remove

      Removed existing alias. This operation can be repeated to remove multiple aliases in one update. It can be combined with add(MonolingualTextValue). Attempt to remove the same alias twice or to remove alias not present in base document (if available) is silently ignored. Removing previously added alias cancels the addition. If recreate(List) was called before, this method will remove the alias from the new alias list.
      Parameters:
      alias - removed alias
      Returns:
      this (fluent method)
      Throws:
      NullPointerException - if alias is null
      IllegalArgumentException - if the alias has language code inconsistent with other aliases
    • recreate

      public AliasUpdateBuilder recreate(List<MonolingualTextValue> aliases)
      Replaces current alias list with completely new alias list. Any previous changes are discarded. To remove all aliases, pass empty list to this method. If the new alias list is identical (including order) to base document alias list (if provided), the update will be empty.
      Parameters:
      aliases - new list of aliases
      Returns:
      this (fluent method)
      Throws:
      NullPointerException - if aliases or any of its items is null
      IllegalArgumentException - if some alias has inconsistent language code or there are duplicates
    • append

      public AliasUpdateBuilder append(AliasUpdate update)
      Replays all changes in provided update into this builder object. Changes are performed as if by calling add(MonolingualTextValue), remove(MonolingualTextValue), and recreate(List) methods.
      Parameters:
      update - alias update to replay
      Returns:
      this (fluent method)
      Throws:
      NullPointerException - if update is null
    • build

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