Introducing Manifold!

Manifold is a breakthrough technology you can use to seamlessly extend Java to compile and load types from non-Java source files. Using this framework your code has direct, type-safe access to metadata such as GraphQL, YAML & JSON Schema files, SQL, and even other programming languages. Building on this foundation Manifold provides an ever growing set of extensions, including comprehensive support for GraphQL, YAML and JSON Schema, extension methods, full featured templates, string interpolation, and a lot more.

Manifold fulfills the promise: your metadata is the single source of truth. There is nothing to manage between your metadata and your code – no code generation steps in your build, no POJOs, no annotation processor steps, no custom class loaders, no runtime agents.

All features are fully supported in IntelliJ IDEA. Author GraphQL schema files and code against them as you make changes without a code generation step. Jump directly to a YAML property from a call site in your code. Quickly rename a JSON field and its usages across your codebase. Use Hotswap to make and test changes to files while debugging. Author templates with the full expressive power of Java and use them type-safely in your code. Etc.

Manifold is easy to use, it’s just a dependency you add to your existing project. See the Setup Guide for details.

What can you do with Manifold?

Meta-programming

Use the framework to gain direct, type-safe access to any type of metadata, such as GraphQL, JSON Schema and YAML. Remove the code gen step in your build process. Check it out!

// Use your User.json schema file directly as a type, no code gen!
User user = User.builder("myid", "mypassword", "Scott")
  .withGender(male)
  .withDob(LocalDate.of(1987, 6, 15))
  .build();
User.request("http://api.example.com/users").postOne(user);

Extensions

Add extension methods to existing Java classes, even String, List, and File. Eliminate boilerplate code. Check it out!

String greeting = "hello";
greeting.myMethod(); // Add your own methods to String!

Structural Typing

Unify disparate APIs. Bridge software components you do not control. Access maps through type-safe interfaces. Check it out!

Map<String, Object> map = new HashMap<>();
MyThingInterface thing = (MyThingInterface) map; // O_o
thing.setFoo(new Foo());
Foo foo = thing.getFoo();
out.println(thing.getClass()); // prints "java.util.HashMap"

Type-safe Reflection

Access private features with @Jailbreak to avoid the drudgery and vulnerability of Java reflection. Check it out!

@Jailbreak Foo foo = new Foo();
// Direct, *type-safe* access to *all* foo's members
foo.privateMethod(x, y, z); 
foo.privateField = value;

Checked Exception Suppression

You now have an option to make checked exceptions behave like unchecked exceptions! No more unintended exception swallowing, no more boilerplate try/catch/wrap/rethrow nonsense.

List<String> strings = ...;
List<URL> urls = list
  .map(URL::new) // No need to handle the MalformedURLException!
  .collect(Collectors.toList());

String Templates (aka String Interpolation)

Embed variables and expressions in String literals, no more clunky string concat! Check it out!

int hour = 15;
// Simple variable access with '$'
String result = "The hour is $hour"; // Yes!!!
// Use expressions with '${}'
result = "It is ${hour > 12 ? hour-12 : hour} o'clock";

Template Files with ManTL

Author template files with the full expressive power of Java, use your templates directly in your code as types. Supports type-safe inclusion of other templates, shared layouts, and more. Check it out!

List<User> users = ...;
String content = abc.example.UserSample.render(users);

A template file abc/example/UserSample.html.mtl

<%@ import java.util.List %>
<%@ import com.example.User %>
<%@ params(List<User> users) %>
<html lang="en">
<body>
<% users.stream()
   .filter(user -> user.getDateOfBirth() != null)
   .forEach(user -> { %>
    User: ${user.getName()} <br>
    DOB: ${user.getDateOfBirth()} <br>
<% }); %>
</body>
</html>

Libraries

Leverage stock Manifold extension libraries for standard Java classes. Save time and reduce boilerplate code.

File file = new File(path);
// Use refreshing extensions to File
String content = file.readText();

IntelliJ

Use the Manifold IntelliJ IDEA plugin to fully leverage Manifold in your development cycle. The plugin provides comprehensive support for IntelliJ features including code completion, navigation, usage searching, refactoring, incremental compilation, hotswap debugging, full-featured template editing, and more.

Learn More