{"id":13485861,"url":"https://github.com/eserating-chwy/siren4j","last_synced_at":"2025-03-27T19:31:52.267Z","repository":{"id":35217446,"uuid":"39476580","full_name":"eserating-chwy/siren4j","owner":"eserating-chwy","description":"Java library for the Siren Hypermedia Type Specification","archived":false,"fork":false,"pushed_at":"2024-05-03T14:17:27.000Z","size":375,"stargazers_count":25,"open_issues_count":7,"forks_count":15,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-30T20:45:54.894Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eserating-chwy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-07-22T00:24:57.000Z","updated_at":"2024-04-23T06:51:31.000Z","dependencies_parsed_at":"2024-10-30T20:42:44.804Z","dependency_job_id":null,"html_url":"https://github.com/eserating-chwy/siren4j","commit_stats":null,"previous_names":["eserating/siren4j"],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eserating-chwy%2Fsiren4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eserating-chwy%2Fsiren4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eserating-chwy%2Fsiren4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eserating-chwy%2Fsiren4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eserating-chwy","download_url":"https://codeload.github.com/eserating-chwy/siren4j/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245910936,"owners_count":20692519,"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","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":[],"created_at":"2024-07-31T18:00:32.885Z","updated_at":"2025-03-27T19:31:51.777Z","avatar_url":"https://github.com/eserating-chwy.png","language":"Java","funding_links":[],"categories":["Projects","项目"],"sub_categories":["Hypermedia Types","超媒体类型"],"readme":"\n\nThis is a java library to help with the creation and use of    \nHypermedia entities as specified by the Siren hypermedia specification. See https://github.com/kevinswiber/siren for more detail on the specification.\n\nIt contains classes to that represent the Siren components (Entity, Link, Action, Field).\nSee: https://github.com/eserating/siren4j/wiki/Siren4J-Components\n\nThese can be easily built with a fluent builder API.\n```java\nEXAMPLE BUILDER:\n   \n    // Create a new self Link\n    Link selfLink = LinkBuilder.newInstance()\n       .setRelationship(Link.RELATIONSHIP_SELF)\n       .setHref(\"/self/link\")\n       .build();\n\n    // Create a new Entity\n    Entity result = EntityBuilder.newInstance()\n       .setEntityClass(\"test\")\n       .addProperty(\"foo\", \"hello\")\n       .addProperty(\"number\", 1)\n       .addLink(selfLink)\n       .build();\n``` \n\nSee: https://github.com/eserating/siren4j/wiki/Fluent-Builder-API\n\nThere is also a resource API that simplifies entity creation and management using reflection and annotations.\n\n\nEXAMPLE RESOURCE:\n```java\n@Siren4JEntity(name = \"video\", uri = \"/videos/{id}\")\npublic class Video extends BaseResource {\n    \n    private String id;    \n    private String name;\n    private String description;\n    private String genre;\n    private Rating rating;\n    @Siren4JSubEntity(uri = \"/video/{parent.id}/reviews\", embeddedLink = true)\n    private CollectionResource\u003cReview\u003e reviews;\n            \n    public String getId() {return id;}\n    public void setId(String id) {this.id = id;}\n    public String getName() {return name;}\n    public void setName(String name) {this.name = name;}\n    public String getDescription() {return description;}\n    public void setDescription(String description) {this.description = description;}\n    public String getGenre() {return genre;}\n    public void setGenre(String genre) {this.genre = genre;}\n    public Rating getRating() {return rating;}\n    public void setRating(Rating rating) {this.rating = rating;}\n    public CollectionResource\u003cReview\u003e getReviews() {return reviews;}\n    public void setReviews(CollectionResource\u003cReview\u003e reviews) {this.reviews = reviews;}\n\n\n    public enum Rating {G, PG, PG13, R, NR, X}\n\n}\n```\nAN INSTANCE OF A RESOURCE CLASS CAN BE CONVERTED LIKE THIS:    \n```java      \n    ResourceConverter converter = ReflectingConverter.newInstance();\n    Entity videoEntity = converter.toEntity(videoResource);\n```\n\nAND WILL RESULT IN SIREN JSON THAT LOOKS LIKE THIS:\n```xml\n{\n  \"class\":[\n    \"video\"\n  ],\n  \"properties\":{\n    \"name\":\"Star Wars\",\n    \"id\":\"z1977\",\n    \"description\":\"An epic science fiction space opera\",\n    \"genre\":\"scifi\",\n    \"rating\":\"PG\"\n  },\n  \"entities\":[\n    {\n      \"class\":[\n        \"siren4J.collectionResource\",\n        \"collection\"\n      ],\n      \"rel\":[\n        \"reviews\"\n      ],\n      \"href\":\"/video/z1977/reviews\"\n    }\n  ],\n  \"links\":[\n    {\n      \"rel\":[\n        \"self\"\n      ],\n      \"href\":\"/videos/z1977\"\n    }\n  ]\n}\n```    \n\n\nSee: https://github.com/eserating/siren4j/wiki/Siren4J-Resource-API\n\n[http://wiki.siren4j.googlecode.com/hg/javadoc/index.html JavaDoc]\n\n*Note:* This projects documentation is a work in progress.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feserating-chwy%2Fsiren4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feserating-chwy%2Fsiren4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feserating-chwy%2Fsiren4j/lists"}