{"id":26903199,"url":"https://github.com/stardog-union/pinto","last_synced_at":"2025-09-25T19:51:50.725Z","repository":{"id":29654561,"uuid":"33196278","full_name":"stardog-union/pinto","owner":"stardog-union","description":"Pinto: A lightweight framework for mapping Java Beans into RDF and back again","archived":false,"fork":false,"pushed_at":"2019-12-13T03:09:52.000Z","size":178,"stargazers_count":42,"open_issues_count":18,"forks_count":16,"subscribers_count":34,"default_branch":"develop","last_synced_at":"2025-09-05T19:58:58.025Z","etag":null,"topics":["java-bean","rdf"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stardog-union.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-31T16:22:54.000Z","updated_at":"2025-08-13T11:13:12.000Z","dependencies_parsed_at":"2022-09-03T18:01:48.626Z","dependency_job_id":null,"html_url":"https://github.com/stardog-union/pinto","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/stardog-union/pinto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stardog-union%2Fpinto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stardog-union%2Fpinto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stardog-union%2Fpinto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stardog-union%2Fpinto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stardog-union","download_url":"https://codeload.github.com/stardog-union/pinto/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stardog-union%2Fpinto/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276975164,"owners_count":25738500,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-25T02:00:09.612Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java-bean","rdf"],"created_at":"2025-04-01T10:05:21.829Z","updated_at":"2025-09-25T19:51:50.675Z","avatar_url":"https://github.com/stardog-union.png","language":"Java","funding_links":[],"categories":["Mapping","Typed"],"sub_categories":["Object to RDF Mapping"],"readme":"# Pinto\n\n![Pinto](https://github.com/Complexible/pinto/raw/master/pinto.png)\n\nPinto is a Java framework for transforming Java beans into RDF (and back).\n\nThe current version is 2.0 as of 2016-06-14.  We're using [git flow](http://nvie.com/posts/a-successful-git-branching-model/)\nfor development.\n\nInspired by [Jackson](https://github.com/FasterXML/jackson) and [Empire](http://github.com/mhgrove/Empire), it aims to\nbe simple and easy to use.  No annotations or configuration are required.  If you have a compliant Java bean Pinto will\nturn it into RDF.\n\nThe [rdf4j](http://rdf4j.com) framework is used to represent RDF primitives such as Graph and Statement.\n\n## Building\n\nTo create the artifacts:\n\n```bash\n$ gradle jar\n```\n\nAnd to run the tests:\n\n```bash\n$ gradle test\n```\n\n## Example Usage\n\nGiven this simple Java Bean:\n\n```java\npublic static final class Person {\n    private String mName;\n\n    public Person() {\n    }\n\n    public Person(final String theName) {\n        mName = theName;\n    }\n\n    public String getName() {\n        return mName;\n    }\n\n    public void setName(final String theName) {\n        mName = theName;\n    }\n\n    @Override\n    public int hashCode() {\n        return Objects.hashCode(mName);\n    }\n\n    @Override\n    public boolean equals(final Object theObj) {\n        if (theObj == this) {\n            return true;\n        }\n        else if (theObj instanceof Person) {\n            return Objects.equal(mName, ((Person) theObj).mName);\n        }\n        else {\n            return false;\n        }\n    }\n}\n```\n\nYou can easily serialize it as RDF:\n\n```java\nGraph aGraph = RDFMapper.create().writeValue(new Person(\"Michael Grove\"));\n```\n\nAnd `aGraph` serialized as NTriples:\n\n```\n\u003ctag:complexible:pinto:f97658c7048377a026111c7806bd7280\u003e \u003ctag:complexible:pinto:name\u003e \"Michael Grove\"^^\u003chttp://www.w3.org/2001/XMLSchema#string\u003e .\n```\n\nAnd if you have that RDF, you can turn it back into a `Person`:\n\n```java\nfinal Person aPerson RDFMapper.create().readValue(aGraph, Person.class)\n```\n\nThis is the quick and dirty example, but for more detailed examples, check out the tests.\n\n## Annotations\n\nPinto does not require annotations to serialize Beans as RDF, but does support a few basic annotations so you can\ncontrol how the object is serialized.\n\n### `@RdfId`\n\nAn annotation which specifies the properties to be used for generating the URI of the object.  By default, a hash of\nthe object itself is used to generate a URI.  But when present on a getter or setter of one or more properties on the\nbean, the values of those properties will be used as the seed for the URI.\n\nNote: There is a secondary mechanism for controlling the URI of an object.  If the object implements `Identifiable` the\nmapper will use the URI returned by `#id` ignoring any `@RdfId` annotated properties.\n\n### `@RdfProperty`\n\nAn annotation which can be applied to a property on a bean, either the getter or the setter, which specifies the\nURI of the property when generating RDF for the bean.  Normally, a URI for the property is auto-generated, but when\nthis annotation is present, the URI specified in the annotation is used instead.  The value of the annotation can also\nbe a QName.\n\n### `@RdfsClass`\n\nAn annotation which can be applied to a class to specify the `rdf:type` of the class when generating the RDF.  Can be\na QName or a URI.  When not present, no `rdf:type` assertion is generated for the object.\n\n### `@Iri`\n\nAnnotation which can be used to control the URI assigned to an `Enum`.  Normally the URI's are generated by Pinto, but\nif you want to map them to specific constants in your ontology, you can use `Iri` to explicitly identify the objects.\n\n```java\npublic enum TestEnum {\n    @Iri(\"urn:my_ontology:test:Foo\")\n    Foo,\n\n    @Iri(\"urn:my_ontology:test:Bar\")\n    Bar,\n}\n```\n\n## Configuration\n\nBy default, `RDFMapper` does not require any configuration, it's meant to generate reasonable RDF out of the box.  There\nare a couple (de)serialization options which are specified by `MappingOptions`:\n\n* `REQUIRE_IDS` - By default, Pinto will auto-generate URIs for objects when `@RdfId` is not specified.  By setting this property to `true` the mapper will not auto-generate URIs, they must be specified explicitly. (default: `false`)\n* `SERIALIZE_COLLECTIONS_AS_LISTS` - When true, collections are serialized as RDF lists.  Otherwise, they're serialized using `Collection#size` separate property assertions. (default: `false`)\n* `IGNORE_INVALID_ANNOTATIONS` - Whether or not to ignore an annotation which is invalid, such as `@RdfProperty` which defines a property with an invalid URI.  Properties with invalid/ignored annotations are simply not used when generating a Bean or RDF. (default: `true`)\n\nBeyond these configuration options, `RDFMapper` has a few other configuration mechanisms that can be specified on its\n`Builder` when creating the mapper:\n\n* `#map(URI, Class)` - Specify the provided type corresponds to instances of the given Java class.  Functions like the `@RdfsClass` annotation.\n* `#namespace(...)` - Methods to specify namespace mappings which are used to expand any QNames used in the annotations\n* `#valueFactory(ValueFactory)` - Provide the `ValueFactory` to be used when creating RDF from a bean\n* `#collectionFactory(CollectionFactory)` - The factory to be used for creating instances of `java.util.Collection`.  Defaults to `DefaultCollectionFactory`\n* `#mapFactory(MapFactory)` - The factory to be used for creating instances of `java.util.Map`.  Defaults to `DefaultMapFactory`\n\n## Custom serialization\n\nIn some cases, an object won't adhere to the Java Bean specification, or it's a third-party class that you don't control\nso you cannot add annotations, but you need a specific serialization.  For these cases `RDFCodec` can be used.  It's\na small plugin to `RDFMapper` which will handle transforming a Java object to/from RDF.  Pinto includes an example\nimplementation of a codec for `java.util.UUID` called `UUIDCodec`.\n\nCodecs are registered when the `RDFMapper` is created via its builder: `Builder.codec(Class\u003cT\u003e, RDFCodec\u003cT\u003e)`\n\n## Why Pinto?\n\nWhy create Pinto when there are similar frameworks available?  Well, the other frameworks, like\n[Empire](http://github.com/mhgrove/Empire) or [Alibaba](https://bitbucket.org/openrdf/alibaba) are focused on more than\njust transforming Beans into RDF and back. Neither are a good fit for _just_ round-tripping between beans and RDF.\n\nA good example is if you're building a JAX-RS based web service and you have some bean in your domain that you'd like\nto serialize as RDF, or accept as RDF, that's normally done with a custom implementation of\n`MessageBodyReader`/`MessageBodyWriter`.  But that implementation is not straight-forward with the heavier-weight\nframeworks.  With Pinto, it's a single line of code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstardog-union%2Fpinto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstardog-union%2Fpinto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstardog-union%2Fpinto/lists"}