Class AliasUpdateBuilder
java.lang.Object
org.wikidata.wdtk.datamodel.helpers.AliasUpdateBuilder
Builder for incremental construction of
AliasUpdate
objects.-
Method Summary
Modifier and TypeMethodDescriptionadd
(MonolingualTextValue alias) Adds new alias.append
(AliasUpdate update) Replays all changes in provided update into this builder object.build()
Creates newAliasUpdate
object with contents of this builder object.static AliasUpdateBuilder
create()
Creates new builder object for constructing alias update.static AliasUpdateBuilder
forAliases
(List<MonolingualTextValue> aliases) Creates new builder object for constructing update of given base revision aliases.recreate
(List<MonolingualTextValue> aliases) Replaces current alias list with completely new alias list.remove
(MonolingualTextValue alias) Removed existing alias.
-
Method Details
-
create
Creates new builder object for constructing alias update.- Returns:
- update builder object
-
forAliases
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 toTermedDocumentUpdateBuilder
anyway, it is usually unnecessary to use this method. It is simpler to initialize the builder withcreate()
.- Parameters:
aliases
- aliases from base revision of the document- Returns:
- update builder object
- Throws:
NullPointerException
- ifaliases
or any of its items isnull
IllegalArgumentException
- if there are duplicate items inaliases
-
add
Adds new alias. This operation can be repeated to add multiple aliases in one update. It can be combined withremove(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. Ifrecreate(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
- ifalias
isnull
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 withadd(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. Ifrecreate(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
- ifalias
isnull
IllegalArgumentException
- if the alias has language code inconsistent with other aliases
-
recreate
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
- ifaliases
or any of its items isnull
IllegalArgumentException
- if some alias has inconsistent language code or there are duplicates
-
append
Replays all changes in provided update into this builder object. Changes are performed as if by callingadd(MonolingualTextValue)
,remove(MonolingualTextValue)
, andrecreate(List)
methods.- Parameters:
update
- alias update to replay- Returns:
this
(fluent method)- Throws:
NullPointerException
- ifupdate
isnull
-
build
Creates newAliasUpdate
object with contents of this builder object.- Returns:
- constructed object
-