@Override public EntityIdValue getSubject() { return statement.getSubject(); }
@Override public EntityIdValue getSubject() { return statement.getSubject(); }
@Override public EntityIdValue getSubject() { return statements.get(0).getSubject(); }
@Override public EntityIdValue getSubject() { return statements.get(0).getSubject(); }
/** * Constructor. * * @param statements * a non-empty list of statements that use the same subject and * main-snak property in their claim */ public StatementGroupImpl(List<Statement> statements) { Validate.notNull(statements, "A non-null list of statements must be provided to create a statement group."); Validate.isTrue(!statements.isEmpty(), "A non-empty list of statements must be provided to create a statement group."); EntityIdValue subject = statements.get(0).getSubject(); PropertyIdValue property = statements.get(0).getMainSnak().getPropertyId(); for(Statement statement : statements) { Validate.isTrue(statement.getSubject().equals(subject), "All statements of a statement group must have the same subject."); Validate.isTrue(statement.getMainSnak().getPropertyId().equals(property), "All statements of a statement group must have the same subject."); } this.statements = statements; }
/** * Get the URI for the given statement. * * @param statement * the statement for which to create a URI * @return the URI */ public static String getStatementUri(Statement statement) { int i = statement.getStatementId().indexOf('$') + 1; return PREFIX_WIKIDATA_STATEMENT + statement.getSubject().getId() + "-" + statement.getStatementId().substring(i); }
/** * Constructor. * * @param statements * a non-empty list of statements that use the same subject and * main-snak property in their claim */ public StatementGroupImpl(List<Statement> statements) { Validate.notNull(statements, "A non-null list of statements must be provided to create a statement group."); Validate.isTrue(!statements.isEmpty(), "A non-empty list of statements must be provided to create a statement group."); EntityIdValue subject = statements.get(0).getSubject(); PropertyIdValue property = statements.get(0).getMainSnak().getPropertyId(); for(Statement statement : statements) { Validate.isTrue(statement.getSubject().equals(subject), "All statements of a statement group must have the same subject."); Validate.isTrue(statement.getMainSnak().getPropertyId().equals(property), "All statements of a statement group must have the same subject."); } this.statements = statements; }
/** * 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(Statement o) { StringBuilder sb = new StringBuilder(); sb.append("[ID ").append(o.getStatementId()).append("] "); sb.append(o.getSubject()).append(": "); sb.append(o.getMainSnak().toString()).append("\n"); for (SnakGroup s : o.getQualifiers()) { sb.append(toString(s)); } if (o.getRank() != StatementRank.NORMAL) { sb.append(" Rank: ").append(o.getRank()).append("\n"); } for (Reference r : o.getReferences()) { sb.append(toString(r)); } return sb.toString(); }
/** * 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(Statement o) { StringBuilder sb = new StringBuilder(); sb.append("[ID ").append(o.getStatementId()).append("] "); sb.append(o.getSubject()).append(": "); sb.append(o.getMainSnak().toString()).append("\n"); for (SnakGroup s : o.getQualifiers()) { sb.append(toString(s)); } if (o.getRank() != StatementRank.NORMAL) { sb.append(" Rank: ").append(o.getRank()).append("\n"); } for (Reference r : o.getReferences()) { sb.append(toString(r)); } return sb.toString(); }
/** * 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(Statement o) { int result; result = o.getSubject().hashCode(); result = prime * result + o.getMainSnak().hashCode(); result = prime * result + o.getQualifiers().hashCode(); result = prime * result + o.getReferences().hashCode(); result = prime * result + o.getRank().hashCode(); result = prime * result + o.getStatementId().hashCode(); return result; }
/** * 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(Statement o) { int result; result = o.getSubject().hashCode(); result = prime * result + o.getMainSnak().hashCode(); result = prime * result + o.getQualifiers().hashCode(); result = prime * result + o.getReferences().hashCode(); result = prime * result + o.getRank().hashCode(); result = prime * result + o.getStatementId().hashCode(); return result; }
/** * Returns true if the parameters are two {@link Statement} 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 equalsStatement(Statement o1, Object o2) { if (o2 == null) { return false; } if (o2 == o1) { return true; } if (!(o2 instanceof Statement)) { return false; } Statement other = (Statement) o2; return o1.getSubject().equals(other.getSubject()) && o1.getMainSnak().equals(other.getMainSnak()) && o1.getQualifiers().equals(other.getQualifiers()) && o1.getReferences().equals(other.getReferences()) && o1.getRank() == other.getRank() && o1.getStatementId().equals(other.getStatementId()); }
/** * Returns true if the parameters are two {@link Statement} 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 equalsStatement(Statement o1, Object o2) { if (o2 == null) { return false; } if (o2 == o1) { return true; } if (!(o2 instanceof Statement)) { return false; } Statement other = (Statement) o2; return o1.getSubject().equals(other.getSubject()) && o1.getMainSnak().equals(other.getMainSnak()) && o1.getQualifiers().equals(other.getQualifiers()) && o1.getReferences().equals(other.getReferences()) && o1.getRank() == other.getRank() && o1.getStatementId().equals(other.getStatementId()); }
/** * Copies a {@link Statement}. * * @param object * object to copy * @return copied object */ public Statement copy(Statement object) { return dataObjectFactory.getStatement( (EntityIdValue) visit(object.getSubject()), copy(object.getMainSnak()), copy(object.getQualifiers()), copyReferences(object.getReferences()), object.getRank(), object.getStatementId()); }
/** * Copies a {@link Statement}. * * @param object * object to copy * @return copied object */ public Statement copy(Statement object) { return dataObjectFactory.getStatement( (EntityIdValue) visit(object.getSubject()), copy(object.getMainSnak()), copy(object.getQualifiers()), copyReferences(object.getReferences()), object.getRank(), object.getStatementId()); }