@Override public Value getValue() { return statement.getValue(); }
@Override public Value getValue() { return statement.getValue(); }
/** * Checks if the given group of statements contains the given value as the * value of a main snak of some statement. * * @param statementGroup * the statement group to scan * @param value * the value to scan for * @return true if value was found */ private boolean containsValue(StatementGroup statementGroup, Value value) { for (Statement s : statementGroup) { if (value.equals(s.getValue())) { return true; } } return false; }
/** * Returns the unique {@link Value} for the given property, or null if there * are zero or many values given in statements for this property. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyIdValue * the property to search for * @return {@link Value} or null */ default Value findStatementValue(PropertyIdValue propertyIdValue) { Statement statement = findStatement(propertyIdValue); return (statement != null) ? statement.getValue() : null; }
/** * Checks if the given statement group contains at least one value of * precision +/-1. * * @param statementGroup * @return */ protected boolean hasPlusMinusOneValues(StatementGroup statementGroup) { if (statementGroup == null) { return false; } for (Statement s : statementGroup) { QuantityValue qv = (QuantityValue) s.getValue(); if (qv != null && isPlusMinusOneValue(qv)) { return true; } } return false; } }
/** * Returns the unique {@link Value} for the given property, or null if there * are zero or many values given in statements for this property. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyIdValue * the property to search for * @return {@link Value} or null */ default Value findStatementValue(PropertyIdValue propertyIdValue) { Statement statement = findStatement(propertyIdValue); return (statement != null) ? statement.getValue() : null; }
/** * Returns the unique {@link Value} for the given property, or null if there * are zero or many values given in statements for this property. Only the * string id of the property is compared, not the site id. This is useful in * situations where all data is known to come from a single site. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyId * the property to search for * @return {@link Value} or null */ default Value findStatementValue(String propertyId) { Statement statement = findStatement(propertyId); return (statement != null) ? statement.getValue() : null; }
/** * Returns the unique {@link Value} for the given property, or null if there * are zero or many values given in statements for this property. Only the * string id of the property is compared, not the site id. This is useful in * situations where all data is known to come from a single site. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyId * the property to search for * @return {@link Value} or null */ default Value findStatementValue(String propertyId) { Statement statement = findStatement(propertyId); return (statement != null) ? statement.getValue() : null; }
/** * Helper method that extracts the list of all {@link ItemIdValue} objects * that are used as values in the given statement group. * * @param statementGroup * the {@link StatementGroup} to extract the data from * @return the list of values */ private List<EntityIdValue> getItemIdValueList(StatementGroup statementGroup) { List<EntityIdValue> result = new ArrayList<>(statementGroup.size()); for (Statement s : statementGroup) { Value v = s.getValue(); if (v instanceof EntityIdValue) { result.add((EntityIdValue) v); } } return result; }
/** * Checks if the given group of statements contains the given value as the * value of a main snak of some statement. * * @param statementGroup * the statement group to scan * @param value * the value to scan for * @return true if value was found */ private boolean containsValue(StatementGroup statementGroup, Value value) { for (Statement s : statementGroup.getStatements()) { if (value.equals(s.getValue())) { return true; } } return false; }
/** * Returns true if there is a statement for the given property and one of * the given values. This is a convenience method for accessing the data * that can be obtained via {@link #getStatementGroups()}. * * @param propertyIdValue * the property to search for * @param values * the set of values to search * @return true if a statement for this property and value exists */ default boolean hasStatementValue(PropertyIdValue propertyIdValue, Set<? extends Value> values) { StatementGroup statementGroup = findStatementGroup(propertyIdValue); if(statementGroup == null) { return false; } for (Statement statement : statementGroup) { if (values.contains(statement.getValue())) { return true; } } return false; }
/** * Returns true if there is a statement for the given property and one of * the given values. This is a convenience method for accessing the data * that can be obtained via {@link #getStatementGroups()}. * * @param propertyIdValue * the property to search for * @param values * the set of values to search * @return true if a statement for this property and value exists */ default boolean hasStatementValue(PropertyIdValue propertyIdValue, Set<? extends Value> values) { StatementGroup statementGroup = findStatementGroup(propertyIdValue); if(statementGroup == null) { return false; } for (Statement statement : statementGroup) { if (values.contains(statement.getValue())) { return true; } } return false; }
/** * Returns true if there is a statement for the given property and one of * the given values. Only the string id of the property is compared, not the * site id. This is useful in situations where all data is known to come * from a single site. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyId * the property to search for * @param values * the set of values to search * @return true if a statement for this property and value exists */ default boolean hasStatementValue(String propertyId, Set<? extends Value> values) { StatementGroup statementGroup = findStatementGroup(propertyId); if(statementGroup == null) { return false; } for (Statement statement : statementGroup) { if (values.contains(statement.getValue())) { return true; } } return false; }
/** * Returns true if there is a statement for the given property and one of * the given values. Only the string id of the property is compared, not the * site id. This is useful in situations where all data is known to come * from a single site. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyId * the property to search for * @param values * the set of values to search * @return true if a statement for this property and value exists */ default boolean hasStatementValue(String propertyId, Set<? extends Value> values) { StatementGroup statementGroup = findStatementGroup(propertyId); if(statementGroup == null) { return false; } for (Statement statement : statementGroup) { if (values.contains(statement.getValue())) { return true; } } return false; }
/** * Helper method that extracts the list of all {@link ItemIdValue} objects * that are used as values in the given statement group. * * @param statementGroup * the {@link StatementGroup} to extract the data from * @return the list of values */ private List<EntityIdValue> getItemIdValueList(StatementGroup statementGroup) { List<EntityIdValue> result = new ArrayList<>(statementGroup .getStatements().size()); for (Statement s : statementGroup.getStatements()) { Value v = s.getValue(); if (v instanceof EntityIdValue) { result.add((EntityIdValue) v); } } return result; }
/** * Checks if the given statement group contains at least one value of * precision +/-1. * * @param statementGroup * @return */ protected boolean hasPlusMinusOneValues(StatementGroup statementGroup) { if (statementGroup == null) { return false; } for (Statement s : statementGroup.getStatements()) { QuantityValue qv = (QuantityValue) s.getValue(); if (qv != null && isPlusMinusOneValue(qv)) { return true; } } return false; } }
/** * Returns true if the given document should be included in the * serialization. * * @param itemDocument * the document to check * @return true if the document should be serialized */ private boolean includeDocument(ItemDocument itemDocument) { for (StatementGroup sg : itemDocument.getStatementGroups()) { // "P19" is "place of birth" on Wikidata if (!"P19".equals(sg.getProperty().getId())) { continue; } for (Statement s : sg) { if (s.getMainSnak() instanceof ValueSnak) { Value v = s.getValue(); // "Q1731" is "Dresden" on Wikidata if (v instanceof ItemIdValue && "Q1731".equals(((ItemIdValue) v).getId())) { return true; } } } } return false; } }
Value value = statement.getValue(); if (!(value instanceof GlobeCoordinatesValue)) { return;
Value value = statement.getValue(); if (!(value instanceof GlobeCoordinatesValue)) { return;