Annotation 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.
Using@ResourceView interface Person extends Resource {@Iri("foaf:firstName")@HashIdString getFirstName(); Person setFirstName(String fn);@Iri("foaf:lastName")@HashIdString 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);
@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:
@HashIdintereface A {@HashId@Iri("dct:identifier")String getId(); }@HashIdintereface B {@HashId@Iri("dct:identifier")String getId(); }
- Author:
- raven
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanBy default, the predicate provided by the @Iri annotation is included in hash id generation from its value.
-
Element Details
-
excludeRdfProperty
boolean excludeRdfPropertyBy 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
-