Class TermUpdateBuilder
java.lang.Object
org.wikidata.wdtk.datamodel.helpers.TermUpdateBuilder
Builder for incremental construction of
TermUpdate
objects.-
Method Summary
Modifier and TypeMethodDescriptionappend
(TermUpdate update) Replays all changes in provided update into this builder object.build()
Creates newTermUpdate
object with contents of this builder object.static TermUpdateBuilder
create()
Creates new builder object for constructing term update.static TermUpdateBuilder
forTerms
(Collection<MonolingualTextValue> terms) Creates new builder object for constructing update of given base revision terms.put
(MonolingualTextValue term) Adds or changes term.Removes term.
-
Method Details
-
create
Creates new builder object for constructing term update.- Returns:
- update builder object
-
forTerms
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 toEntityUpdateBuilder
anyway, it is usually unnecessary to use this method. It is simpler to initialize the builder withcreate()
.- Parameters:
terms
- terms from base revision of the document- Returns:
- update builder object
- Throws:
NullPointerException
- ifterms
or any of its items isnull
IllegalArgumentException
- if there are duplicate items interms
-
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 orremove(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
- ifterm
isnull
-
remove
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 orput(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
- iflanguageCode
isnull
IllegalArgumentException
- iflanguageCode
is blank
-
append
Replays all changes in provided update into this builder object. Changes are performed as if by callingput(MonolingualTextValue)
andremove(String)
methods.- Parameters:
update
- term update to replay- Returns:
this
(fluent method)- Throws:
NullPointerException
- ifupdate
isnull
-
build
Creates newTermUpdate
object with contents of this builder object.- Returns:
- constructed object
-