Skip to content
This repository has been archived by the owner on Dec 12, 2018. It is now read-only.

kburger/rdf4j-beans

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rdf4j-beans

Build Status Coverage Status Codacy Badge Maven Central Javadocs

Java beans IO library for RDF4J.

usage

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!");

changelog

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.