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 newStatementDocumentUpdateobject with contents of this builder object.static LexemeUpdateBuilderforBaseRevision(LexemeDocument revision) Creates new builder object for constructing update of given base lexeme entity revision.static LexemeUpdateBuilderforBaseRevisionId(LexemeIdValue lexemeId, long revisionId) Creates new builder object for constructing update of lexeme entity with given revision ID.static LexemeUpdateBuilderforEntityId(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, forEntityIdMethods 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- iflexemeIdisnullIllegalArgumentException- iflexemeIdis 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- iflexemeIdisnullIllegalArgumentException- iflexemeIdis 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- ifrevisionisnullIllegalArgumentException- ifrevisionhas placeholder ID
-
updateStatements
Description copied from class:StatementDocumentUpdateBuilderUpdates 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:
updateStatementsin 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- iflanguageisnullIllegalArgumentException- iflanguageis 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- ifcategoryisnullIllegalArgumentException- ifcategoryis 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- ifupdateisnull
-
addSense
Adds sense to the lexeme. Ifsensehas 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- ifsenseisnull
-
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- ifupdateisnullIllegalArgumentException- 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- ifsenseIdisnullIllegalArgumentException- ifsenseIdis not valid or if such ID does not exist in base revision (if available)
-
addForm
Adds form to the lexeme. Ifformhas 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- ifformisnull
-
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- ifupdateisnullIllegalArgumentException- 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- ifformIdisnullIllegalArgumentException- ifformIdis 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- ifupdateisnullIllegalArgumentException- ifupdatecannot be applied to base entity revision (if available)
-
build
Description copied from class:StatementDocumentUpdateBuilderCreates newStatementDocumentUpdateobject with contents of this builder object.- Specified by:
buildin classStatementDocumentUpdateBuilder- Returns:
- constructed object
-