TRIPLE-CHIST-ERA / VoIDToJava

Generate a java package for data described using VoID (ReadOnly-ORM for SPARQL)
MIT License
0 stars 2 forks source link

Allow registering custom literals and their transformations #17

Open JervenBolleman opened 2 weeks ago

JervenBolleman commented 2 weeks ago

If a SPARQL endpoint uses custom datatypes for literals we should be able to inject custom classes and their transformations.

This means we need to allow someone to register the string form of a lambda that is used to convert the string from the SPARQL result into the desired java object.

e.g. assume a datatype money:USD sparql ?myWallet ex:has "100000000"^^money:USD .

then we register a lambda form and return type.

iriToDatatype.put("http://example.org/money/USD", USD.class); 

and

datatypeToJava.put(USD.class, ""(v) -> new $T(v.stringValue())")

Where $T is used by javapoet to import the right java class.

So that we can generate code like

IRI myWalletIri = .... 
USD myMoney = new Wallet(myWalletIri).hasUSD();