java-tilt is a Java based language binding for the Transparency Information Language and Toolkit.
1/2: Add this to pom.xml:
<dependency>
<groupId>cloud.implementation.tilt</groupId>
<artifactId>tilt</artifactId>
<version>0.0.1</version>
</dependency>
2/2: Run via command line:
$ mvn install
See more examples and tests here.
/*
Generate new Tilt instance from scratch
*/
Tilt tilt = new Tilt();
Controller controller = new Controller();
controller.setName("Example Company SE");
tilt.setController(controller);
System.out.println(tilt.toString());
/*
Validation Example
*/
String DOCUMENT_URL = "https://raw.githubusercontent.com/Transparency-Information-Language/schema/master/tilt.json";
TiltValidator.validateDocumentFromUrl(DOCUMENT_URL);
/*
Load tilt instance from json and modify properties
*/
try {
String instance = IOUtils.toString(URI.create(DOCUMENT_URL), "utf8");
System.out.println(instance.indexOf("meta"));
Tilt t = Converter.fromJsonString(instance);
System.out.println(t.getMeta().getHash());
t.getMeta().setHash("42");
System.out.println(Converter.toJsonString(t));
System.out.println(t.getMeta().toString());
System.out.println(t.toString());
} catch (IOException e) {
e.printStackTrace();
}