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
ConstructorsModifierConstructorDescriptionprotectedItemDocumentBuilder(ItemDocument initialDocument) Constructor to start the build from an existing item.protectedItemDocumentBuilder(ItemIdValue itemIdValue) Constructor to start the build from a blank item. -
Method Summary
Modifier and TypeMethodDescriptionbuild()Returns theItemDocumentthat has been built.static ItemDocumentBuilderforItemId(ItemIdValue itemIdValue) Starts the construction of anItemDocumentwith the given id.static ItemDocumentBuilderfromItemDocument(ItemDocument initialDocument) Starts the construction of anItemDocumentfrom an existing value.protected ItemDocumentBuildergetThis()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, withStatementMethods 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 anItemDocumentwith the given id.- Parameters:
itemIdValue- id of the newly constructed item document- Returns:
- builder object to continue construction
-
fromItemDocument
Starts the construction of anItemDocumentfrom an existing value.- Parameters:
initialDocument- the item to start the construction from- Returns:
- builder object to continue construction
-
build
Returns theItemDocumentthat has been built.- Specified by:
buildin 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:
withEntityIdin classEntityDocumentBuilder<ItemDocumentBuilder,ItemDocument> - Parameters:
entityId- the entity id, which must be an ItemIdValue- Returns:
- builder object to continue construction
-
getThis
Description copied from class:AbstractDataObjectBuilderReturns the current object with the correct builder type.- Specified by:
getThisin classAbstractDataObjectBuilder<ItemDocumentBuilder,ItemDocument> - Returns:
- this
-