https://github.com/mchlrch/rdf4j-utils2
Utililty code related to rdf4j
https://github.com/mchlrch/rdf4j-utils2
rdf rdf4j
Last synced: 2 months ago
JSON representation
Utililty code related to rdf4j
- Host: GitHub
- URL: https://github.com/mchlrch/rdf4j-utils2
- Owner: mchlrch
- License: bsd-3-clause
- Created: 2021-03-12T07:41:48.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-10-11T14:28:05.000Z (over 1 year ago)
- Last Synced: 2023-10-12T00:05:07.495Z (over 1 year ago)
- Topics: rdf, rdf4j
- Language: Java
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rdf4j-utils2
Utililty code related to [rdf4j](https://rdf4j.org/).
## ModelBuilderFacade
The `ModelBuilderFacade` is a (partial) facade over the [rdf4j ModelBuilder](https://rdf4j.org/javadoc/latest/org/eclipse/rdf4j/model/util/ModelBuilder.html).
It includes some convenience methods for adding collections and for skipping over nullable values.Usage example:
```
Namespace nsData = new SimpleNamespace("", "http://data.example.org/");ModelBuilderFacade mbf = new ModelBuilderFacade(nsData);
// shaka is likely, but not guaranteed
String shaka = Math.random() >= 0.1 ? "hang loose" : null;mbf.subject(":Hawaii")
.addEach("rdfs:label", Arrays.asList("Hawaiʻi", "Big Island"))
.addNullable("rdfs:comment", shaka);
```For more examples, have a look at the [unit tests](https://github.com/mchlrch/rdf4j-utils2/tree/main/ch.miranet.rdf4jutils2/src/test/java/ch/miranet/rdf4jutils2/model/util).