Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Aklakan opened this issue Aug 22, 2019 · 1 comment
Open

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

Aklakan opened this issue Aug 22, 2019 · 1 comment

Comments

@Aklakan
Copy link
Member

Aklakan commented Aug 22, 2019

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
Copy link
Member Author

Aklakan commented Jun 28, 2021

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:

  • On get-access convert null to the default value (do not write to the model)

  • On get-access write the default value into the model if the result would be null (i.e. get with a write side-effect)

  • On get-access write null into the model if the result would otherwise be the default value

  • On set replace the default value with null

  • On set replace null with the default value

  • On set just set the given value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant