SmartDataAnalytics / jena-sparql-api

A collection of Jena-extensions for hiding SPARQL-complexity from the application layer
Other
57 stars 14 forks source link

Enhance annotation and/or processor with default value support #28

Open Aklakan opened 5 years ago

Aklakan commented 5 years ago

Allow to specify a default value for the case that no triples exist for a property. E.g. the absence of certain triples may indicate a value of 'true' for a property. Most likely, we can reuse some existing annotation for that purpose.

interface Foo {
   @Iri("eg:bar")
   @Default(true) // Something along these lines
   Boolean isEnabled();
}
Aklakan commented 3 years ago

There is a @DefaultValue annotation for exposing Java functions as SPARQL functions:

    @IriNs(GeoSPARQL_URI.GEOF_URI)
    public static Geometry simplifyDp(
            Geometry geom,
            @DefaultValue("0") double tolerance,
            @DefaultValue("true") boolean ensureValid) {
        DouglasPeuckerSimplifier simplifier = new DouglasPeuckerSimplifier(geom);
        simplifier.setDistanceTolerance(tolerance);
        simplifier.setEnsureValid(ensureValid);
        Geometry result = simplifier.getResultGeometry();
        return result;
    }

This annotation could be reused for the purpose of the issue.

There are however different possible semantics for which it should be possible to specify it unambiguously: