Class StatementUpdateBuilder
StatementUpdate
objects.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionAdds statement to the entity.append
(StatementUpdate update) Replays all changes in provided update into this builder object.build()
Creates newStatementUpdate
object with contents of this builder object.static StatementUpdateBuilder
create()
Creates new builder object for constructing statement update.static StatementUpdateBuilder
create
(EntityIdValue subject) Creates new builder object for constructing statement update of given subject.static StatementUpdateBuilder
forStatementGroups
(Collection<StatementGroup> groups) Creates new builder object for constructing update of given base revision statement groups.static StatementUpdateBuilder
forStatementGroups
(EntityIdValue subject, Collection<StatementGroup> groups) Creates new builder object for constructing update of given base revision statement groups with given subject.static StatementUpdateBuilder
forStatements
(Collection<Statement> statements) Creates new builder object for constructing update of given base revision statements.static StatementUpdateBuilder
forStatements
(EntityIdValue subject, Collection<Statement> statements) Creates new builder object for constructing update of given base revision statements with given subject.Removes existing statement from the entity.Replaces existing statement in the entity.
-
Method Details
-
create
Creates new builder object for constructing statement update.- Returns:
- update builder object
-
create
Creates new builder object for constructing statement update of given subject. All added or replaced statements must have the same subject ID.- Parameters:
subject
- statement subject ornull
for unspecified ID- Returns:
- update builder object
- Throws:
IllegalArgumentException
- if subject is a placeholder ID
-
forStatements
Creates new builder object for constructing update of given base revision statements. Provided statements will be used to check correctness of changes.Since all changes will be checked after the
StatementUpdate
is passed toEntityDocumentBuilder
anyway, it is usually unnecessary to use this method. It is simpler to initialize the builder withcreate()
.- Parameters:
statements
- statements from base revision of the document- Returns:
- update builder object
- Throws:
NullPointerException
- ifstatements
or any of its items isnull
IllegalArgumentException
- if any statement is missing statement ID or statement subjects are inconsistent or placeholders
-
forStatements
public static StatementUpdateBuilder forStatements(EntityIdValue subject, Collection<Statement> statements) Creates new builder object for constructing update of given base revision statements with given subject. Provided statements will be used to check correctness of changes. All provided statements as well as added or replaced statements must have the provided subject ID.Since all changes will be checked after the
StatementUpdate
is passed toEntityDocumentBuilder
anyway, it is usually unnecessary to use this method. It is simpler to initialize the builder withcreate()
.- Parameters:
subject
- statement subject ornull
for unspecified IDstatements
- statements from base revision of the document- Returns:
- update builder object
- Throws:
NullPointerException
- ifstatements
or any of its items isnull
IllegalArgumentException
- if any statement is missing statement ID or statement subjects are inconsistent or placeholders
-
forStatementGroups
Creates new builder object for constructing update of given base revision statement groups. Provided statements will be used to check correctness of changes.Since all changes will be checked after the
StatementUpdate
is passed toEntityDocumentBuilder
anyway, it is usually unnecessary to use this method. It is simpler to initialize the builder withcreate()
.- Parameters:
groups
- statement groups from base revision of the document- Returns:
- update builder object
- Throws:
NullPointerException
- ifgroups
isnull
IllegalArgumentException
- if any group isnull
or any statement is missing statement ID or statement subjects are inconsistent or placeholders
-
forStatementGroups
public static StatementUpdateBuilder forStatementGroups(EntityIdValue subject, Collection<StatementGroup> groups) Creates new builder object for constructing update of given base revision statement groups with given subject. Provided statements will be used to check correctness of changes. All provided statements as well as added or replaced statements must have the provided subject ID.Since all changes will be checked after the
StatementUpdate
is passed toEntityDocumentBuilder
anyway, it is usually unnecessary to use this method. It is simpler to initialize the builder withcreate()
.- Parameters:
subject
- statement subject ornull
for unspecified IDgroups
- statement groups from base revision of the document- Returns:
- update builder object
- Throws:
NullPointerException
- ifgroups
isnull
IllegalArgumentException
- if any group isnull
or any statement is missing statement ID or statement subjects are inconsistent or placeholders
-
add
Adds statement to the entity. Ifstatement
has an ID (perhaps because it is a modified copy of another statement), its ID is stripped to ensure the statement is added and no other statement is modified.- Parameters:
statement
- new statement to add- Returns:
this
(fluent method)- Throws:
NullPointerException
- ifstatement
isnull
IllegalArgumentException
- if statement's subject is inconsistent with other statements or it is a placeholder ID
-
replace
Replaces existing statement in the entity. Providedstatement
must have statement ID identifying statement to replace. Calling this method overrides any previous changes made to the same statement ID by this method orremove(String)
.If base revision statements were provided, existence of the statement is checked. Any attempt to replace some statement with identical statement is silently ignored, resulting in empty update.
- Parameters:
statement
- replacement for existing statement- Returns:
this
(fluent method)- Throws:
NullPointerException
- ifstatement
isnull
IllegalArgumentException
- ifstatement
does not have statement ID or it is not among base revision statements (if available) or its subject is inconsistent with other statements or a placeholder ID
-
remove
Removes existing statement from the entity. Calling this method overrides any previous changes made to the same statement ID byreplace(Statement)
. Removing the same statement ID twice is silently tolerated.If base revision statements were provided, this method checks that statement with this ID exists in the base revision.
- Parameters:
statementId
- ID of the removed statement- Returns:
this
(fluent method)- Throws:
NullPointerException
- ifstatementId
isnull
IllegalArgumentException
- ifstatementId
is empty or it is not among base revision statements (if available)
-
append
Replays all changes in provided update into this builder object. Changes are performed as if by callingadd(Statement)
,replace(Statement)
, andremove(String)
methods.- Parameters:
update
- statement update to replay- Returns:
this
(fluent method)- Throws:
NullPointerException
- ifupdate
isnull
IllegalArgumentException
- if updated or removed statement is not among base revision statements (if available)
-
build
Creates newStatementUpdate
object with contents of this builder object.- Returns:
- constructed object
-