Class ItemDocumentBuilder
java.lang.Object
org.wikidata.wdtk.datamodel.helpers.AbstractDataObjectBuilder<T,O>
org.wikidata.wdtk.datamodel.helpers.EntityDocumentBuilder<ItemDocumentBuilder,ItemDocument>
org.wikidata.wdtk.datamodel.helpers.ItemDocumentBuilder
Builder class to construct
ItemDocument
objects.- Author:
- Markus Kroetzsch
-
Constructor Summary
ModifierConstructorDescriptionprotected
ItemDocumentBuilder
(ItemDocument initialDocument) Constructor to start the build from an existing item.protected
ItemDocumentBuilder
(ItemIdValue itemIdValue) Constructor to start the build from a blank item. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Returns theItemDocument
that has been built.static ItemDocumentBuilder
forItemId
(ItemIdValue itemIdValue) Starts the construction of anItemDocument
with the given id.static ItemDocumentBuilder
fromItemDocument
(ItemDocument initialDocument) Starts the construction of anItemDocument
from an existing value.protected ItemDocumentBuilder
getThis()
Returns the current object with the correct builder type.withEntityId
(EntityIdValue entityId) Changes the entity value id for the constructed document.withSiteLink
(String title, String siteKey, ItemIdValue... badges) Adds an additional site link to the constructed document.withSiteLink
(SiteLink siteLink) Adds an additional site link to the constructed document.Methods inherited from class org.wikidata.wdtk.datamodel.helpers.EntityDocumentBuilder
getStatementGroups, withAlias, withAlias, withDescription, withDescription, withLabel, withLabel, withRevisionId, withStatement
Methods inherited from class org.wikidata.wdtk.datamodel.helpers.AbstractDataObjectBuilder
prepareBuild
-
Constructor Details
-
ItemDocumentBuilder
Constructor to start the build from a blank item.- Parameters:
itemIdValue
-
-
ItemDocumentBuilder
Constructor to start the build from an existing item.- Parameters:
initialDocument
- the item to start the build from
-
-
Method Details
-
forItemId
Starts the construction of anItemDocument
with the given id.- Parameters:
itemIdValue
- id of the newly constructed item document- Returns:
- builder object to continue construction
-
fromItemDocument
Starts the construction of anItemDocument
from an existing value.- Parameters:
initialDocument
- the item to start the construction from- Returns:
- builder object to continue construction
-
build
Returns theItemDocument
that has been built.- Specified by:
build
in classAbstractDataObjectBuilder<ItemDocumentBuilder,
ItemDocument> - Returns:
- constructed item document
- Throws:
IllegalStateException
- if the object was built already
-
withSiteLink
Adds an additional site link to the constructed document.- Parameters:
siteLink
- the additional site link
-
withSiteLink
Adds an additional site link to the constructed document.- Parameters:
title
- the title of the linked pagesiteKey
- identifier of the site, e.g., "enwiki"badges
- one or more badges
-
withEntityId
Changes the entity value id for the constructed document. SeeEntityDocument.getEntityId()
.- Overrides:
withEntityId
in classEntityDocumentBuilder<ItemDocumentBuilder,
ItemDocument> - Parameters:
entityId
- the entity id, which must be an ItemIdValue- Returns:
- builder object to continue construction
-
getThis
Description copied from class:AbstractDataObjectBuilder
Returns the current object with the correct builder type.- Specified by:
getThis
in classAbstractDataObjectBuilder<ItemDocumentBuilder,
ItemDocument> - Returns:
- this
-