HalBuilder Core
Java
talios Merge branch 'master' into develop
* master:
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release halbuilder5-5.1.3
Latest commit 612088e Dec 11, 2017
Permalink
Failed to load latest commit information.
src
.gitignore
.travis.yml
LICENSE-2.0.txt Added license Jan 7, 2013
README.md
checkstyle-supressions.xml
pom.xml [maven-release-plugin] prepare for next development iteration Dec 11, 2017

README.md

Halbuilder is a simple Java API for generating and consuming HAL documents conforming to the HAL Specification.

travis codecov

Generating Local Resources

Map<String,Object> friend = HashMap.of("name", "Mike", "age", 36);
ResourceRepresentation<Map<String,Object>> owner =
  ResourceRepresentation.create("http://example.com/mike", friend)
    .withLink("td:friend", "http://example.com/mamund")

Map<String,Object> todoMeta = HashMap.of(
  "created_at", "2010-01-16", "updated_at", "2017-06-13",
  "summary", "An example list");

ResourceRepresentation<Map<String,Object>> halResource =
  ResourceRepresentation.create("http://example.com/todo-list", todoMeta)
    .withLink("td:search", "/todo-list/search;{searchterm}")
    .withLink("td:description", "/todo-list/description")
    .withRepresentation("td:owner", owner);

JsonRepresentationWriter jsonRepresentationWriter =
  JsonRepresentationWriter.create();

ByteString representation = jsonRepresentationWriter.print(accountRepWithLinks);
System.out.println(representation.utf8());

Reading Local Resources

JsonRepresentationReader jsonRepresentationReader =
  JsonRepresentationReader.create();

ResourceRepresentation<ByteString> representation =
  jsonRepresentationReader.read(
    new InputStreamReader(Some.class.getResourceAsStream("/test.json")));

// or as a type

ResourceRepresentation<Person> personRepresentation =
  jsonRepresentationReader.read(
    new InputStreamReader(Some.class.getResourceAsStream("/test.json")),
    Person.class);

Apache Maven

HalBuilder is deployed to Apache Maven Central under the following coordinates:

<dependency>
  <groupId>com.theoryinpractise</groupId>
  <artifactId>halbuilder5</artifactId>
  <version>5.0.1</version>
</dependency>

Website

More documentation is available from the main website at gotohal.net.

Development Forum

Email support and discussion is available on the development forum.