-
Notifications
You must be signed in to change notification settings - Fork 1
Description
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.