Annotation Interface HashId


@Retention(RUNTIME) public @interface HashId
Annotation to mark properties of a Resource implementation as contributing to the identity of that annotated Resource. The interpretation of @HashId depends on the value of the annotated property: (.) Resource typed properties have a structural hash taken from the outgoing properties (.) The value of String typed properties are used directly as the hash. Special and non-IRI characters should be avoided.
 @ResourceView
 interface Person
   extends Resource
 {
   @Iri("foaf:firstName")
   @HashId
   String getFirstName();
   Person setFirstName(String fn);

   @Iri("foaf:lastName")
   @HashId
   String getLastName();
   Person setLastName(String fn);

   @Iri("foaf:age")
   Integer getAge();
   Person setAge(Integer age);
 }

 Person person = ModelFactory.createDefaultModel().as(Person.class)
   .setFirstName("Foo")
   .setLastName("Bar")
   .setAge(20)

 // Every person with same first/last name will yield the same hash - regardless of age
 String hash = JenaPluginUtils.computeHashId(person);

 
Using @HashId on class level allows post-processing all obtained hashes with a hash based on the class. By default it is derived from the class name. The following example demonstrates that even if .getId() of A and B yield the same hash, the final hash will be combined with the hash of A and B respectively:
 @HashId
 intereface A {
   @HashId
   @Iri("dct:identifier")
   String getId();
 }

 @HashId
 intereface B {
   @HashId
   @Iri("dct:identifier")
   String getId();
 }
 
Author:
raven
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    By default, the predicate provided by the @Iri annotation is included in hash id generation from its value.
  • Element Details

    • excludeRdfProperty

      boolean excludeRdfProperty
      By default, the predicate provided by the @Iri annotation is included in hash id generation from its value. Setting this flag to false makes hash id computation dependent only on the value for that predicate.
      Default:
      false