/** * 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(); }
/** * 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(); }
/** * 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()); }
/** * 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()); }
/** * 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(); }
/** * 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(); }
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()); }
/** * 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()); } }
/** * 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()); } }
this.qualifiersOrder = new ArrayList<>(); for(SnakGroup qualifiersGroup : qualifiers) { this.qualifiers.put(qualifiersGroup.getProperty().getId(), qualifiersGroup.getSnaks()); this.qualifiersOrder.add(qualifiersGroup.getProperty().getId());
this.qualifiersOrder = new ArrayList<>(); for(SnakGroup qualifiersGroup : qualifiers) { this.qualifiers.put(qualifiersGroup.getProperty().getId(), qualifiersGroup.getSnaks()); this.qualifiersOrder.add(qualifiersGroup.getProperty().getId());
void writeReference(Reference reference, Resource resource) throws RDFHandlerException { this.rdfWriter.writeTripleValueObject(resource, RdfWriter.RDF_TYPE, RdfWriter.WB_REFERENCE); for (SnakGroup snakGroup : reference.getSnakGroups()) { this.snakRdfConverter.setSnakContext(resource, PropertyContext.REFERENCE); for (Snak snak : snakGroup.getSnaks()) { snak.accept(this.snakRdfConverter); } } } }
void writeClaim(Resource claimResource, Claim claim) { this.snakRdfConverter.setSnakContext(claimResource, PropertyContext.VALUE); claim.getMainSnak().accept(this.snakRdfConverter); this.snakRdfConverter.setSnakContext(claimResource, PropertyContext.QUALIFIER); for (SnakGroup snakGroup : claim.getQualifiers()) { for (Snak snak : snakGroup.getSnaks()) { snak.accept(this.snakRdfConverter); } } }