Java beans IO library for RDF4J.
Add the rdf4j-beans
dependency in your POM:
<dependency>
<groupId>com.github.kburger</groupId>
<artifactId>rdf4j-beans</artifactId>
<version>0.3.0</version>
</dependency>
Annotate your beans:
@Type("http://example.com/Type")
public class MyBean {
@Predicate(value = "http://purl.org/dc/terms/title", isLiteral = true)
private String title;
public MyBean(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
}
Invoke the mapper:
BeanMapper mapper = new BeanMapper();
mapper.write(new OutputStreamWriter(System.out), new MyBean("example"), "http://example.com/subject", RDFFormat.TURTLE);
Or read from source:
@prefix ex: <http://example.com/> .
@prefix dc: <http://purl.org/dc/terms> .
ex:subject a ex:Type ;
dc:title "Hello world!" .
MyBean bean = mapper.read(new StringReader(content), MyBean.class, "http://example.com/subject", RDFFormat.TURTLE);
assert bean.getTitle().equals("Hello world!");
0.3.0
- Support for inherited properties.
0.2.0
- Support for bean deserialization.
- Fix for handling property null values.
0.1.0
- Initial release.
- Support for bean serialization.