/** * Constructor. * <p> * The order of the snaks groups provided will be respected. * the properties used by the snak groups should be distinct. * * @param groups * the snaks group which form the reference */ public ReferenceImpl(List<SnakGroup> groups) { propertyOrder = new ArrayList<>(groups.size()); snaks = new HashMap<>(groups.size()); for(SnakGroup group : groups) { propertyOrder.add(group.getProperty().getId()); snaks.put(group.getProperty().getId(), group.getSnaks()); } }
/** * Returns a hash code for the given object. * * @see java.lang.Object#hashCode() * @param o * the object to create a hash for * @return the hash code of the object */ public static int hashCode(SnakGroup o) { return o.getSnaks().hashCode(); }
/** * Count the statements and property uses of an item or property document. * * @param usageStatistics * statistics object to store counters in * @param statementDocument * document to count the statements of */ protected void countStatements(UsageStatistics usageStatistics, StatementDocument statementDocument) { // Count Statement data: for (StatementGroup sg : statementDocument.getStatementGroups()) { // Count Statements: usageStatistics.countStatements += sg.size(); // Count uses of properties in Statements: countPropertyMain(usageStatistics, sg.getProperty(), sg.size()); for (Statement s : sg) { for (SnakGroup q : s.getQualifiers()) { countPropertyQualifier(usageStatistics, q.getProperty(), q.size()); } for (Reference r : s.getReferences()) { usageStatistics.countReferencedStatements++; for (SnakGroup snakGroup : r.getSnakGroups()) { countPropertyReference(usageStatistics, snakGroup.getProperty(), snakGroup.size()); } } } } }
/** * Adds all qualifiers from the given {@link SnakGroup} to the constructed * statement. * * @param qualifiers * the group of qualifiers to add * @return builder object to continue construction */ public StatementBuilder withQualifiers(SnakGroup qualifiers) { getQualifierList(qualifiers.getProperty()).addAll(qualifiers); return getThis(); }
/** * Copies a {@link SnakGroup}. * * @param object * object to copy * @return copied object */ public SnakGroup copy(SnakGroup object) { List<Snak> snaks = new ArrayList<>(object.size()); for (Snak snak : object) { snaks.add(copy(snak)); } return dataObjectFactory.getSnakGroup(snaks); }
/** * Returns a hash code for the given object. * * @see java.lang.Object#hashCode() * @param o * the object to create a hash for * @return the hash code of the object */ public static int hashCode(SnakGroup o) { return o.getSnaks().hashCode(); }
countPropertyQualifier(q.getProperty(), q.size()); countPropertyReference(snakGroup.getProperty(), snakGroup.size());
/** * Adds all qualifiers from the given {@link SnakGroup} to the constructed * statement. * * @param qualifiers * the group of qualifiers to add * @return builder object to continue construction */ public StatementBuilder withQualifiers(SnakGroup qualifiers) { getQualifierList(qualifiers.getProperty()).addAll(qualifiers); return getThis(); }
/** * Copies a {@link SnakGroup}. * * @param object * object to copy * @return copied object */ public SnakGroup copy(SnakGroup object) { List<Snak> snaks = new ArrayList<>(object.size()); for (Snak snak : object) { snaks.add(copy(snak)); } return dataObjectFactory.getSnakGroup(snaks); }
/** * Constructor. * <p> * The order of the snaks groups provided will be respected. * the properties used by the snak groups should be distinct. * * @param groups * the snaks group which form the reference */ public ReferenceImpl(List<SnakGroup> groups) { propertyOrder = new ArrayList<>(groups.size()); snaks = new HashMap<>(groups.size()); for(SnakGroup group : groups) { propertyOrder.add(group.getProperty().getId()); snaks.put(group.getProperty().getId(), group.getSnaks()); } }
/** * Returns true if the parameters are two {@link SnakGroup} objects with * exactly the same data. It does not matter if they are different * implementations of the interface as long as their content is the same. * * @param o1 * the first object to compare * @param o2 * the second object to compare * @return true if both objects are equal */ public static boolean equalsSnakGroup(SnakGroup o1, Object o2) { if (o2 == null) { return false; } if (o2 == o1) { return true; } return o2 instanceof SnakGroup && o1.getSnaks().equals(((SnakGroup) o2).getSnaks()); }
Integer qualifierId = getNumId(snakGroup.getProperty() .getId(), false); if (propertyRecord.qualifiers.containsKey(qualifierId)) {
this.qualifiersOrder = new ArrayList<>(); for(SnakGroup qualifiersGroup : qualifiers) { this.qualifiers.put(qualifiersGroup.getProperty().getId(), qualifiersGroup.getSnaks()); this.qualifiersOrder.add(qualifiersGroup.getProperty().getId());
/** * Returns true if the parameters are two {@link SnakGroup} objects with * exactly the same data. It does not matter if they are different * implementations of the interface as long as their content is the same. * * @param o1 * the first object to compare * @param o2 * the second object to compare * @return true if both objects are equal */ public static boolean equalsSnakGroup(SnakGroup o1, Object o2) { if (o2 == null) { return false; } if (o2 == o1) { return true; } return o2 instanceof SnakGroup && o1.getSnaks().equals(((SnakGroup) o2).getSnaks()); }
this.qualifiersOrder = new ArrayList<>(); for(SnakGroup qualifiersGroup : qualifiers) { this.qualifiers.put(qualifiersGroup.getProperty().getId(), qualifiersGroup.getSnaks()); this.qualifiersOrder.add(qualifiersGroup.getProperty().getId());
/** * Returns a human-readable string representation of the given object. * * @see java.lang.Object#toString() * @param o * the object to represent as string * @return a string representation of the object */ public static String toString(SnakGroup o) { final String indent = " "; StringBuilder result = new StringBuilder(); for (Snak s : o.getSnaks()) { result.append(indent) .append(s.toString()) .append("\n"); } return result.toString(); }
for (Statement s : sg.getStatements()) { for (SnakGroup q : s.getClaim().getQualifiers()) { countPropertyQualifier(usageStatistics, q.getProperty(), q .getSnaks().size()); for (SnakGroup snakGroup : r.getSnakGroups()) { countPropertyReference(usageStatistics, snakGroup.getProperty(), snakGroup.getSnaks() .size());
/** * Returns a human-readable string representation of the given object. * * @see java.lang.Object#toString() * @param o * the object to represent as string * @return a string representation of the object */ public static String toString(SnakGroup o) { final String indent = " "; StringBuilder result = new StringBuilder(); for (Snak s : o.getSnaks()) { result.append(indent) .append(s.toString()) .append("\n"); } return result.toString(); }
countPropertyQualifier(q.getProperty(), q.getSnaks().size()); countPropertyReference(snakGroup.getProperty(), snakGroup.getSnaks().size());
public static String getReferenceUri(Reference reference) { md.reset(); for (SnakGroup snakgroup : reference.getSnakGroups()) { for (Snak snak : snakgroup.getSnaks()) { updateMessageDigestWithInt(md, snak.hashCode()); } } return PREFIX_WIKIDATA + VALUE_PREFIX_REFERENCE + bytesToHex(md.digest()); }