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 newStatementUpdateobject with contents of this builder object.static StatementUpdateBuildercreate()Creates new builder object for constructing statement update.static StatementUpdateBuildercreate(EntityIdValue subject) Creates new builder object for constructing statement update of given subject.static StatementUpdateBuilderforStatementGroups(Collection<StatementGroup> groups) Creates new builder object for constructing update of given base revision statement groups.static StatementUpdateBuilderforStatementGroups(EntityIdValue subject, Collection<StatementGroup> groups) Creates new builder object for constructing update of given base revision statement groups with given subject.static StatementUpdateBuilderforStatements(Collection<Statement> statements) Creates new builder object for constructing update of given base revision statements.static StatementUpdateBuilderforStatements(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 ornullfor 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
StatementUpdateis passed toEntityDocumentBuilderanyway, 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- ifstatementsor any of its items isnullIllegalArgumentException- 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
StatementUpdateis passed toEntityDocumentBuilderanyway, it is usually unnecessary to use this method. It is simpler to initialize the builder withcreate().- Parameters:
subject- statement subject ornullfor unspecified IDstatements- statements from base revision of the document- Returns:
- update builder object
- Throws:
NullPointerException- ifstatementsor any of its items isnullIllegalArgumentException- 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
StatementUpdateis passed toEntityDocumentBuilderanyway, 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- ifgroupsisnullIllegalArgumentException- if any group isnullor 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
StatementUpdateis passed toEntityDocumentBuilderanyway, it is usually unnecessary to use this method. It is simpler to initialize the builder withcreate().- Parameters:
subject- statement subject ornullfor unspecified IDgroups- statement groups from base revision of the document- Returns:
- update builder object
- Throws:
NullPointerException- ifgroupsisnullIllegalArgumentException- if any group isnullor any statement is missing statement ID or statement subjects are inconsistent or placeholders
-
add
Adds statement to the entity. Ifstatementhas 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- ifstatementisnullIllegalArgumentException- if statement's subject is inconsistent with other statements or it is a placeholder ID
-
replace
Replaces existing statement in the entity. Providedstatementmust 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- ifstatementisnullIllegalArgumentException- ifstatementdoes 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- ifstatementIdisnullIllegalArgumentException- ifstatementIdis 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- ifupdateisnullIllegalArgumentException- if updated or removed statement is not among base revision statements (if available)
-
build
Creates newStatementUpdateobject with contents of this builder object.- Returns:
- constructed object
-