/** * 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(GlobeCoordinatesValue o) { int result; result = o.getGlobe().hashCode(); long value; value = Double.valueOf(o.getLatitude()).hashCode(); result = prime * result + (int) (value ^ (value >>> 32)); value = Double.valueOf(o.getLongitude()).hashCode(); result = prime * result + (int) (value ^ (value >>> 32)); value = Double.valueOf(o.getPrecision()).hashCode(); result = prime * result + (int) (value ^ (value >>> 32)); 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(GlobeCoordinatesValue o) { int result; result = o.getGlobe().hashCode(); long value; value = Double.valueOf(o.getLatitude()).hashCode(); result = prime * result + (int) (value ^ (value >>> 32)); value = Double.valueOf(o.getLongitude()).hashCode(); result = prime * result + (int) (value ^ (value >>> 32)); value = Double.valueOf(o.getPrecision()).hashCode(); result = prime * result + (int) (value ^ (value >>> 32)); return result; }
public static String getGlobeCoordinatesValueUri(GlobeCoordinatesValue value) { md.reset(); updateMessageDigestWithString(md, value.getGlobe()); updateMessageDigestWithLong(md, Double.valueOf(value.getLatitude()) .hashCode()); updateMessageDigestWithLong(md, Double.valueOf(value.getLongitude()) .hashCode()); updateMessageDigestWithLong(md, Double.valueOf(value.getPrecision()) .hashCode()); return PREFIX_WIKIDATA_VALUE + bytesToHex(md.digest()); }
public static String getGlobeCoordinatesValueUri(GlobeCoordinatesValue value) { md.reset(); updateMessageDigestWithString(md, value.getGlobe()); updateMessageDigestWithLong(md, Double.valueOf(value.getLatitude()) .hashCode()); updateMessageDigestWithLong(md, Double.valueOf(value.getLongitude()) .hashCode()); updateMessageDigestWithLong(md, Double.valueOf(value.getPrecision()) .hashCode()); return PREFIX_WIKIDATA + VALUE_PREFIX_GLOBECOORDS + bytesToHex(md.digest()); }
/** * Returns true if the parameters are two {@link GlobeCoordinatesValue} * 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 equalsGlobeCoordinatesValue(GlobeCoordinatesValue o1, Object o2) { if (o2 == null) { return false; } if (o2 == o1) { return true; } if (!(o2 instanceof GlobeCoordinatesValue)) { return false; } GlobeCoordinatesValue other = (GlobeCoordinatesValue) o2; return o1.getLatitude() == other.getLatitude() && o1.getLongitude() == other.getLongitude() && o1.getPrecision() == other.getPrecision() && o1.getGlobe().equals(other.getGlobe()); }
/** * Copies a {@link GlobeCoordinatesValue}. * * @param object * object to copy * @return copied object */ public GlobeCoordinatesValue copy(GlobeCoordinatesValue object) { return dataObjectFactory.getGlobeCoordinatesValue( object.getLatitude(), object.getLongitude(), object.getPrecision(), object.getGlobe()); }
/** * Copies a {@link GlobeCoordinatesValue}. * * @param object * object to copy * @return copied object */ public GlobeCoordinatesValue copy(GlobeCoordinatesValue object) { return dataObjectFactory.getGlobeCoordinatesValue( object.getLatitude(), object.getLongitude(), object.getPrecision(), object.getGlobe()); }
/** * Returns true if the parameters are two {@link GlobeCoordinatesValue} * 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 equalsGlobeCoordinatesValue(GlobeCoordinatesValue o1, Object o2) { if (o2 == null) { return false; } if (o2 == o1) { return true; } if (!(o2 instanceof GlobeCoordinatesValue)) { return false; } GlobeCoordinatesValue other = (GlobeCoordinatesValue) o2; return o1.getLatitude() == other.getLatitude() && o1.getLongitude() == other.getLongitude() && o1.getPrecision() == other.getPrecision() && o1.getGlobe().equals(other.getGlobe()); }
@Override public void writeValue(GlobeCoordinatesValue value, Resource resource) throws RDFHandlerException { this.rdfWriter.writeTripleValueObject(resource, RdfWriter.RDF_TYPE, RdfWriter.WB_GLOBE_COORDINATES_VALUE); this.rdfWriter.writeTripleLiteralObject(resource, RdfWriter.WB_LATITUDE, Double.valueOf(value.getLatitude()) .toString(), RdfWriter.XSD_DOUBLE); this.rdfWriter.writeTripleLiteralObject(resource, RdfWriter.WB_LONGITUDE, Double.valueOf(value.getLongitude()) .toString(), RdfWriter.XSD_DOUBLE); this.rdfWriter.writeTripleLiteralObject(resource, RdfWriter.WB_GC_PRECISION, Double.valueOf(value.getPrecision()) .toString(), RdfWriter.XSD_DOUBLE); URI globeUri; try { globeUri = this.rdfWriter.getUri(value.getGlobe()); } catch (IllegalArgumentException e) { logger.warn("Invalid globe URI \"" + value.getGlobe() + "\". Assuming Earth (" + GlobeCoordinatesValue.GLOBE_EARTH + ")."); globeUri = this.rdfWriter.getUri(GlobeCoordinatesValue.GLOBE_EARTH); } this.rdfWriter.writeTripleValueObject(resource, RdfWriter.WB_GLOBE, globeUri); }
@Override public void writeValue(GlobeCoordinatesValue value, Resource resource) throws RDFHandlerException { this.rdfWriter.writeTripleValueObject(resource, RdfWriter.RDF_TYPE, RdfWriter.WB_GLOBE_COORDINATES_VALUE); this.rdfWriter.writeTripleLiteralObject(resource, RdfWriter.WB_GEO_LATITUDE, Double.valueOf(value.getLatitude()) .toString(), RdfWriter.XSD_DOUBLE); this.rdfWriter.writeTripleLiteralObject(resource, RdfWriter.WB_GEO_LONGITUDE, Double.valueOf(value.getLongitude()) .toString(), RdfWriter.XSD_DOUBLE); this.rdfWriter.writeTripleLiteralObject(resource, RdfWriter.WB_GEO_PRECISION, Double.valueOf(value.getPrecision()) .toString(), RdfWriter.XSD_DOUBLE); IRI globeUri; try { globeUri = this.rdfWriter.getUri(value.getGlobe()); } catch (IllegalArgumentException e) { logger.warn("Invalid globe URI \"" + value.getGlobe() + "\". Assuming Earth (" + GlobeCoordinatesValue.GLOBE_EARTH + ")."); globeUri = this.rdfWriter.getUri(GlobeCoordinatesValue.GLOBE_EARTH); } this.rdfWriter.writeTripleValueObject(resource, RdfWriter.WB_GEO_GLOBE, globeUri); }