Class LexemeUpdateBuilder
java.lang.Object
org.wikidata.wdtk.datamodel.helpers.EntityUpdateBuilder
org.wikidata.wdtk.datamodel.helpers.StatementDocumentUpdateBuilder
org.wikidata.wdtk.datamodel.helpers.LexemeUpdateBuilder
Builder for incremental construction of
LexemeUpdate
objects.-
Method Summary
Modifier and TypeMethodDescriptionaddForm
(FormDocument form) Adds form to the lexeme.addSense
(SenseDocument sense) Adds sense to the lexeme.append
(LexemeUpdate update) Replays all changes in provided update into this builder object.build()
Creates newStatementDocumentUpdate
object with contents of this builder object.static LexemeUpdateBuilder
forBaseRevision
(LexemeDocument revision) Creates new builder object for constructing update of given base lexeme entity revision.static LexemeUpdateBuilder
forBaseRevisionId
(LexemeIdValue lexemeId, long revisionId) Creates new builder object for constructing update of lexeme entity with given revision ID.static LexemeUpdateBuilder
forEntityId
(LexemeIdValue lexemeId) Creates new builder object for constructing update of lexeme entity with given ID.removeForm
(FormIdValue formId) Removes existing form from the lexeme.removeSense
(SenseIdValue senseId) Removes existing sense from the lexeme.setLanguage
(ItemIdValue language) Sets lexeme language.setLexicalCategory
(ItemIdValue category) Sets lexical category of the lexeme.updateForm
(FormUpdate update) Updates existing form in the lexeme.updateLemmas
(TermUpdate update) Updates lemmas.updateSense
(SenseUpdate update) Updates existing sense in the lexeme.updateStatements
(StatementUpdate update) Updates entity statements.Methods inherited from class org.wikidata.wdtk.datamodel.helpers.StatementDocumentUpdateBuilder
forBaseRevision, forBaseRevisionId, forEntityId
Methods inherited from class org.wikidata.wdtk.datamodel.helpers.EntityUpdateBuilder
forBaseRevision
-
Method Details
-
forBaseRevisionId
Creates new builder object for constructing update of lexeme entity with given revision ID.- Parameters:
lexemeId
- ID of the lexeme that is to be updatedrevisionId
- ID of the base lexeme revision to be updated or zero if not available- Returns:
- update builder object
- Throws:
NullPointerException
- iflexemeId
isnull
IllegalArgumentException
- iflexemeId
is a placeholder ID
-
forEntityId
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
- iflexemeId
isnull
IllegalArgumentException
- iflexemeId
is a placeholder ID
-
forBaseRevision
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
- ifrevision
isnull
IllegalArgumentException
- ifrevision
has placeholder ID
-
updateStatements
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 classStatementDocumentUpdateBuilder
- Parameters:
update
- statement update, possibly empty- Returns:
this
(fluent method)
-
setLanguage
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
- iflanguage
isnull
IllegalArgumentException
- iflanguage
is an invalid ID
-
setLexicalCategory
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
- ifcategory
isnull
IllegalArgumentException
- ifcategory
is an invalid ID
-
updateLemmas
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
- ifupdate
isnull
-
addSense
Adds sense to the lexeme. Ifsense
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
- ifsense
isnull
-
updateSense
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
- ifupdate
isnull
IllegalArgumentException
- if the sense does not exist in base revision (if available) or the update cannot be applied to itIllegalStateException
- if the sense was removed by callingremoveSense(SenseIdValue)
-
removeSense
Removes existing sense from the lexeme. Removing the same sense ID twice is silently tolerated. Any prior changes made by callingupdateSense(SenseUpdate)
are discarded.- Parameters:
senseId
- ID of the removed sense- Returns:
this
(fluent method)- Throws:
NullPointerException
- ifsenseId
isnull
IllegalArgumentException
- ifsenseId
is not valid or if such ID does not exist in base revision (if available)
-
addForm
Adds form to the lexeme. Ifform
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
- ifform
isnull
-
updateForm
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
- ifupdate
isnull
IllegalArgumentException
- if the form does not exist in base revision (if available) or the update cannot be applied to itIllegalStateException
- if the form was removed by callingremoveForm(FormIdValue)
-
removeForm
Removes existing form from the lexeme. Calling this method overrides any previous changes made to the same form ID byupdateForm(FormUpdate)
. Removing the same form ID twice is silently tolerated.- Parameters:
formId
- ID of the removed form- Returns:
this
(fluent method)- Throws:
NullPointerException
- ifformId
isnull
IllegalArgumentException
- ifformId
is not valid or if such ID does not exist in current version of the lexeme document (if available)
-
append
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
- ifupdate
isnull
IllegalArgumentException
- ifupdate
cannot be applied to base entity revision (if available)
-
build
Description copied from class:StatementDocumentUpdateBuilder
Creates newStatementDocumentUpdate
object with contents of this builder object.- Specified by:
build
in classStatementDocumentUpdateBuilder
- Returns:
- constructed object
-