Class PropertyDocumentImpl
java.lang.Object
org.wikidata.wdtk.datamodel.implementation.EntityDocumentImpl
org.wikidata.wdtk.datamodel.implementation.TermedStatementDocumentImpl
org.wikidata.wdtk.datamodel.implementation.PropertyDocumentImpl
- All Implemented Interfaces:
EntityDocument,LabeledDocument,LabeledStatementDocument,PropertyDocument,StatementDocument,TermedDocument,TermedStatementDocument
Jackson implementation of
PropertyDocument.- Author:
- Fredo Erxleben, Antonin Delpeuch, Markus Kroetzsch
-
Field Summary
FieldsModifier and TypeFieldDescriptionThis is what is called claim in the JSON model.protected final Map<String,MonolingualTextValue> Fields inherited from class org.wikidata.wdtk.datamodel.implementation.TermedStatementDocumentImpl
aliases, descriptionsFields inherited from class org.wikidata.wdtk.datamodel.implementation.EntityDocumentImpl
entityId, revisionId, siteIri -
Constructor Summary
ConstructorsConstructorDescriptionPropertyDocumentImpl(String jsonId, Map<String, MonolingualTextValue> labels, Map<String, MonolingualTextValue> descriptions, Map<String, List<MonolingualTextValue>> aliases, Map<String, List<StatementImpl.PreStatement>> claims, String datatype, long revisionId, String siteIri) Constructor.PropertyDocumentImpl(PropertyIdValue id, List<MonolingualTextValue> labels, List<MonolingualTextValue> descriptions, List<MonolingualTextValue> aliases, List<StatementGroup> statements, DatatypeIdValue datatype, long revisionId) Constructor for instances that are built manually, rather than from JSON. -
Method Summary
Modifier and TypeMethodDescriptionAdds a Statement to a given collection of statement groups.protected static Map<String,MonolingualTextValue> constructTermMap(List<MonolingualTextValue> terms) booleanfindStatementGroup(String propertyIdValue) Find a statement group by its property id, without checking for equality with the site IRI.Returns an iterator that provides access to all statements, without considering the statement groups.Get the datatype id of the datatype defined for this property.Return the ID of the item that the data refers to.Returns the "claims".Returns the JSON string version of the property's datatype.Return a Map from Wikibase language codes to labels.Return the list of all StatementGroups stored for this item.inthashCode()Removes statement ids from a collection of statement groups.toString()withAliases(String language, List<MonolingualTextValue> aliases) Returns a new version of this document with a new list of aliases for the given language code.withDescription(MonolingualTextValue newDescription) Returns a new version of this document with a new description (which overrides any existing description).withEntityId(PropertyIdValue newEntityId) Returns a new version of this document with updated ID.withLabel(MonolingualTextValue newLabel) Returns a new version of this document with a new label (which overrides any existing label for this language).withoutStatementIds(Set<String> statementIds) Returns a new version of this document where all statements matching any of the statement ids provided have been removed.withRevisionId(long newRevisionId) Returns a copy of this document with an updated revision id.withStatement(Statement statement) Returns a new version of this document which includes the statement provided.protected static Map<String,MonolingualTextValue> withTerm(Map<String, MonolingualTextValue> values, MonolingualTextValue value) Methods inherited from class org.wikidata.wdtk.datamodel.implementation.TermedStatementDocumentImpl
getAliases, getDescriptions, getSiteIri, withAliasesMethods inherited from class org.wikidata.wdtk.datamodel.implementation.EntityDocumentImpl
getJsonId, getRevisionIdMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.wikidata.wdtk.datamodel.interfaces.EntityDocument
getRevisionIdMethods inherited from interface org.wikidata.wdtk.datamodel.interfaces.LabeledDocument
findLabel, getLabelsMethods inherited from interface org.wikidata.wdtk.datamodel.interfaces.StatementDocument
findStatement, findStatement, findStatementEntityIdValue, findStatementEntityIdValue, findStatementGlobeCoordinatesValue, findStatementGlobeCoordinatesValue, findStatementGroup, findStatementGroup, findStatementItemIdValue, findStatementItemIdValue, findStatementMonolingualTextValue, findStatementMonolingualTextValue, findStatementPropertyIdValue, findStatementPropertyIdValue, findStatementQuantityValue, findStatementQuantityValue, findStatementStringValue, findStatementStringValue, findStatementTimeValue, findStatementTimeValue, findStatementValue, findStatementValue, getAllStatements, getStatementGroups, hasStatement, hasStatement, hasStatementValue, hasStatementValue, hasStatementValue, hasStatementValueMethods inherited from interface org.wikidata.wdtk.datamodel.interfaces.TermedDocument
findDescription, getAliases, getDescriptions
-
Field Details
-
labels
-
claims
This is what is called claim in the JSON model. It corresponds to the statement group in the WDTK model.
-
-
Constructor Details
-
PropertyDocumentImpl
public PropertyDocumentImpl(PropertyIdValue id, List<MonolingualTextValue> labels, List<MonolingualTextValue> descriptions, List<MonolingualTextValue> aliases, List<StatementGroup> statements, DatatypeIdValue datatype, long revisionId) Constructor for instances that are built manually, rather than from JSON.- Parameters:
id- the id of the property that data is aboutlabels- the list of labels of this property, with at most one label for each language codedescriptions- the list of descriptions of this property, with at most one description for each language codealiases- the list of aliases of this propertystatements- the list of statement groups of this item; all of them must have the given itemIdValue as their subjectdatatype- the datatype of that propertyrevisionId- the revision ID or 0 if not known; seeEntityDocument.getRevisionId()
-
PropertyDocumentImpl
public PropertyDocumentImpl(String jsonId, Map<String, MonolingualTextValue> labels, Map<String, MonolingualTextValue> descriptions, Map<String, List<MonolingualTextValue>> aliases, Map<String, List<StatementImpl.PreStatement>> claims, String datatype, long revisionId, String siteIri) Constructor. Creates an instance by deserializing from JSON.
-
-
Method Details
-
getJsonDatatype
Returns the JSON string version of the property's datatype. Note thatgetDatatype()is already used for another function of the interface.- Returns:
- string datatype
-
getEntityId
Description copied from interface:PropertyDocumentReturn the ID of the item that the data refers to.- Specified by:
getEntityIdin interfaceEntityDocument- Specified by:
getEntityIdin interfacePropertyDocument- Returns:
- item id
-
getDatatype
Description copied from interface:PropertyDocumentGet the datatype id of the datatype defined for this property.- Specified by:
getDatatypein interfacePropertyDocument- Returns:
DatatypeIdValue
-
hashCode
public int hashCode() -
equals
-
toString
-
withEntityId
Description copied from interface:PropertyDocumentReturns a new version of this document with updated ID.- Specified by:
withEntityIdin interfacePropertyDocument- Parameters:
newEntityId- new ID of the document- Returns:
- document with updated ID
-
withRevisionId
Description copied from interface:TermedDocumentReturns a copy of this document with an updated revision id.- Specified by:
withRevisionIdin interfaceEntityDocument- Specified by:
withRevisionIdin interfaceLabeledDocument- Specified by:
withRevisionIdin interfaceLabeledStatementDocument- Specified by:
withRevisionIdin interfacePropertyDocument- Specified by:
withRevisionIdin interfaceStatementDocument- Specified by:
withRevisionIdin interfaceTermedDocument- Specified by:
withRevisionIdin interfaceTermedStatementDocument
-
withLabel
Description copied from interface:TermedDocumentReturns a new version of this document with a new label (which overrides any existing label for this language).- Specified by:
withLabelin interfaceLabeledDocument- Specified by:
withLabelin interfaceLabeledStatementDocument- Specified by:
withLabelin interfacePropertyDocument- Specified by:
withLabelin interfaceTermedDocument- Specified by:
withLabelin interfaceTermedStatementDocument
-
withDescription
Description copied from interface:TermedDocumentReturns a new version of this document with a new description (which overrides any existing description).- Specified by:
withDescriptionin interfacePropertyDocument- Specified by:
withDescriptionin interfaceTermedDocument- Specified by:
withDescriptionin interfaceTermedStatementDocument
-
withAliases
Description copied from interface:TermedDocumentReturns a new version of this document with a new list of aliases for the given language code. Any existing aliases for this language will be discarded.- Specified by:
withAliasesin interfacePropertyDocument- Specified by:
withAliasesin interfaceTermedDocument- Specified by:
withAliasesin interfaceTermedStatementDocument- Parameters:
language- the language code for which the aliases should be setaliases- the aliases to set for this language. The language codes they contain should all match the supplied language.
-
withStatement
Description copied from interface:StatementDocumentReturns a new version of this document which includes the statement provided. If the identifier of this statement matches that of any other statement for the same property, then the existing statement will be replaced by the new one. Otherwise, the new statement will be added at the end of the list of statements in this group.- Specified by:
withStatementin interfaceLabeledStatementDocument- Specified by:
withStatementin interfacePropertyDocument- Specified by:
withStatementin interfaceStatementDocument- Specified by:
withStatementin interfaceTermedStatementDocument- Parameters:
statement- the statement to add or update in the document
-
withoutStatementIds
Description copied from interface:StatementDocumentReturns a new version of this document where all statements matching any of the statement ids provided have been removed. These statements can use different properties.- Specified by:
withoutStatementIdsin interfaceLabeledStatementDocument- Specified by:
withoutStatementIdsin interfacePropertyDocument- Specified by:
withoutStatementIdsin interfaceStatementDocument- Specified by:
withoutStatementIdsin interfaceTermedStatementDocument- Parameters:
statementIds- the identifiers of the statements to remove
-
getLabels
Description copied from interface:LabeledDocumentReturn a Map from Wikibase language codes to labels.- Specified by:
getLabelsin interfaceLabeledDocument- Returns:
- the map of labels
-
constructTermMap
protected static Map<String,MonolingualTextValue> constructTermMap(List<MonolingualTextValue> terms) -
withTerm
protected static Map<String,MonolingualTextValue> withTerm(Map<String, MonolingualTextValue> values, MonolingualTextValue value) -
getStatementGroups
Description copied from interface:StatementDocumentReturn the list of all StatementGroups stored for this item. The order of StatementGroups is significant.- Specified by:
getStatementGroupsin interfaceStatementDocument- Returns:
- list of StatementGroups
-
findStatementGroup
Find a statement group by its property id, without checking for equality with the site IRI. More efficient implementation than the default one.- Specified by:
findStatementGroupin interfaceStatementDocument- Parameters:
propertyIdValue- the property to search for- Returns:
StatementGroupor null
-
getJsonClaims
Returns the "claims". Only used by Jackson.JSON "claims" correspond to statement groups in the WDTK model. You should use
StatementDocument.getStatementGroups()to obtain this data.- Returns:
- map of statement groups
-
getAllStatements
Description copied from interface:StatementDocumentReturns an iterator that provides access to all statements, without considering the statement groups. The order of statements is preserved.- Specified by:
getAllStatementsin interfaceStatementDocument- Returns:
- iterator over all statements
-
addStatementToGroups
protected static Map<String,List<Statement>> addStatementToGroups(Statement statement, Map<String, List<Statement>> claims) Adds a Statement to a given collection of statement groups. If the statement id is not null and matches that of an existing statement, this statement will be replaced.- Parameters:
statement-claims-- Returns:
-
removeStatements
protected static Map<String,List<Statement>> removeStatements(Set<String> statementIds, Map<String, List<Statement>> claims) Removes statement ids from a collection of statement groups.- Parameters:
statementIds-claims-- Returns:
-