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

Constructor for CurieUtil not strongly typed or informative. #3

Open
julesjacobsen opened this issue Mar 8, 2017 · 3 comments
Open

Comments

@julesjacobsen
Copy link
Contributor

julesjacobsen commented Mar 8, 2017

The current constructor is not informative about what it actually expects in the map. Just two strings? What should they contain? What is the expected key and value? What happens when they don't conform to the required format?

CurieUtil curieUtil = new CurieUtil(new HashMap<String, String>());

It might be easier to figure out with a couple of new types - CuriePrefix and CurieIri. These are basically wrapped strings, but ought to do some format checking when used. e.g.

CuriePrefix hpPrefix= CuriePrefix.parse("HP");
CurieIri hpIri = CurieIri.parse("http://purl.obolibrary.org/obo/HP_");

or maybe less verbose would be:

CurieMapping hpMapping = CurieMapping.of("HP", "http://purl.obolibrary.org/obo/HP_");
//or maybe use a builder to avoid getting the strings the wrong way round at the expense of added verbosity
Curie hpCurie = Curie.builder().prefix("HP").iri("http://purl.obolibrary.org/obo/HP_").build();
//then add these to the CurieUtil.
CurieUtil curieUtil = CurieUtil.just(hpMapping);

the prefix can then be checked that it doesn't contain any illegal characters, the IRI should be properly formed etc... This will save people headaches down the line when things start failing oddly due to incorrect mappings as happens in owlsim3. Sure currently it's disarmingly simple, but I think you're missing out on the benefits of type safety.

@jnguyenx
Copy link
Contributor

jnguyenx commented Mar 8, 2017

I'm curious about the actual checks that you'll do to check if a CURIE is valid. I didn't find any formal way to identify a string as a CURIE or an IRI.

See SciGraph/SciGraph#147 (comment)

@balhoff
Copy link

balhoff commented Mar 8, 2017

There are constraints on valid strings for the prefix and local part: https://www.w3.org/TR/curie/

The prefix must conform to NCName, for example.

@jnguyenx
Copy link
Contributor

jnguyenx commented Mar 8, 2017 via email

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

3 participants