What is Manifold?

Manifold plugs into Java to supplement it with game-changing features, including Type-safe Metaprogramming, Extension Methods, Operator Overloading, Unit Expressions, Java Template Engine, Preprocessor, and more. All fully supported in IntelliJ IDEA. Simply add Manifold to your project and begin taking advantage of it.

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);

Extension Methods

Add your own 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!

Operator Overloading

Implement operator methods on any type to directly support arithmetic, relational, and unit operators.

// BigDecimal expressions
if (bigDec1 > bigDec2) {
  BigDecimal result = bigDec1 + bigDec2;
  ...
}
// Implement operators for any type
MyType value = myType1 + myType2;

Unit Expressions

Unit or binding operations are unique to the Manifold framework. They provide a powerfully concise syntax and can be applied to a wide range of applications.

import static manifold.science.util.UnitConstants.*; // kg, m, s, ft, etc
...
Length distance = 100 mph * 3 hr;
Force f = 5.2 kg m/s/s; // same as 5.2 N
Mass infant = 9 lb + 8.71 oz;

Ranges

Easily work with the Range API using unit expressions. Simply import the RangeFun constants to create ranges.

// imports the `to`, `step`, and other "binding" constants
import static manifold.collections.api.range.RangeFun.*;
...
for (int i: 1 to 5) {
  out.println(i);
}

for (Mass m: 0kg to 10kg step 22r unit g) {
  out.println(m);
}

Science

Use the manifold-science framework to type-safely incorporate units and precise measurements into your applications.

import static manifold.science.util.UnitConstants.*; // kg, m, s, ft, etc.
...
Velocity rate = 65mph;
Time time = 1min + 3.7sec;
Length distance = rate * time;

Preprocessor

Use familiar directives such as #define and #if to conditionally compile your Java projects. The preprocessor offers a simple and convenient way to support multiple build targets with a single codebase.   Check it out!

#if JAVA_8_OR_LATER
  @Override
  public void setTime(LocalDateTime time) {...)
#else
  @Override
  public void setTime(Calendar time) {...}
#endif

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 Handling

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

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>

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, integrated preprocessor, and more.

manifold ij plugin

Note the Manifold Plugin for IntelliJ IDEA is free for use with IntelliJ IDEA Community Edition which like the Manifold project is free and open source. The plugin is also commercially available on a trial basis via the JetBrains Marketplace for use with IntelliJ IDEA Ultimate Edition.

Projects

The Manifold project consists of the core Manifold framework and a collection of sub-projects implementing SPIs provided by the core framework. Each project represents a separate dependency you can easily add to your project:

Manifold : Core

Manifold : GraphQL
Manifold : JSON
Manifold : YAML
Manifold : Properties
Manifold : Image
Manifold : Dark Java
Manifold : JavaScript

Manifold : Java Extension

Manifold : Templates (ManTL)

Manifold : String Interpolation
Manifold : [Un]checked Exceptions

Manifold : Preprocessor

Manifold : Science

Manifold : Collections
Manifold : I/0
Manifold : Text

Manifold : All  (Über jar)

Experiment with sample projects:

Learn More