Table of Contents

Overview

Manifold plugs directly into Java to supplement it with powerful features you can use directly in your projects:

Type-safe Metaprogramming via Type Manifolds

Bridging the worlds of data and code, a type manifold acts as an adapter to automatically connect data resources to Java’s type system. The core Manifold framework seamlessly plugs into the Java compiler enabling a type manifold to transform structured data into a data type directly accessible in your Java code eliminating code generation build steps otherwise required with conventional tools. Additionally the Manifold plugin for IntelliJ IDEA provides comprehensive integration for type manifolds. Types are always in sync; changes you make to resources are immediately available in the type system without a compilation step. Code completion, navigation, usage searching, refactoring, incremental compilation, hotswap debugging – all seamlessly integrated. With type manifolds a data file is a virtual data type.

To illustrate, consider this simple properties resource file:

/abc/MyProperties.properties

chocolate = Chocolate
chocolate.milk = Milk chocolate
chocolate.dark = Dark chocolate

Normally in Java you access a properties file like this:

Properties myProperties = new Properties();
myProperties.load(getClass().getResourceAsStream("/abc/MyProperties.properties"));
String myMessage = myProperties.getProperty("chocolate.milk");

As with any resource file a properties file is foreign to Java’s type system – there is no direct, type-safe access to it. Instead you access it indirectly using boilerplate library code sprinkled with hard-coded strings.

By contrast, with the Properties type manifold you access a properties file directly as a type:

String myMessage = MyProperties.chocolate.milk;

Concise and type-safe, with no additional build steps to engage.

Any data resource is a potential type manifold, including file schemas, query languages, database definitions, data services, templates, spreadsheets, and programming languages.

Manifold provides type manifolds for:

Java Extensions via the Extension Manifold

The extension manifold is a special kind of type manifold that lets you augment existing Java classes including Java’s own runtime classes such as String. You can add new methods, annotations, and interfaces to any type your project uses.

Let’s say you want to make a new method on String so you can straightforwardly echo a String to the console. Normally with Java you might write a “Util” library like this:

public class MyStringUtil {
  public static void echo(String value) {
    System.out.println(value);
  }
}

And you’d use it like this:

MyStringUtil.echo("Java");

Instead with Manifold you create an Extension Class:

@Extension
public class MyStringExtension {
  public static void echo(@This String thiz) {
    System.out.println(thiz);
  }
}

Here we’ve added a new echo() method to String, so we use it like this:

"Java".echo();

Extensions eliminate a lot of intermediate code such as “Util” and “Manager” libraries as well as Factory classes. As a consequence extensions naturally promote higher levels of object-orientation, which result in more readable and maintainable code. Additionally, with the Manifold IntelliJ plugin you can use code-completion which conveniently presents all the extension methods available on an extended class:

There’s a lot more to the extension manifold including operator overloading, unit expressions, structural interfaces, which are similar to interfaces in the Go and TypeScript languages. See the Java Extension Manifold for full coverage of these features.

Benefits

Manifold’s core technology is a dramatic departure from conventional Java tooling. There are no code generation steps in the build, no extra build target files to manage, no annotation processors, and no extra class loaders to engage at runtime.

Benefits of this approach include:

Manifold is just a dependency you can drop into your existing project – you can begin using it incrementally without having to rewrite classes or conform to a new way of doing things.

IDE Support

Use the Manifold IntelliJ IDEA plugin to experience Manifold to its fullest.

The plugin currently supports most high-level IntelliJ features including:

The IntelliJ plugin provides comprehensive support for Manifold. Use code completion to discover and use type manifolds, extension methods and structural interfaces. Jump directly from usages of extension methods to their declarations. Likewise, jump directly from references to resource elements and find usages of them in your code. Watch your JSON/YAML/XML/CSV, images, properties, templates, and custom type manifolds come alive as types. Changes you make are instantly available in your code.

Install the plugin directly from IntelliJ via:

SettingsPluginsMarketplace ➜ search: Manifold

Projects

The Manifold framework consists of the core project and a collection of sub-projects implementing SPIs provided by the core. Each project represents a separate dependency you can use directly in your project. See details in each projects’ docs.

Core Framework

Resource Manifolds

Java Extension Manifold

Java Templates Framework

Java Compiler Extensions

Java Preprocessor

Java Science

Java Extension Libraries

Manifold “Fat” Jar

Manifold : All  (Über jar)

Sample Projects

Setup

Manifold is designed to work with most build systems, including Maven and Gradle.

The Manifold root project consists of several sub-projects you can include separately in your build, see Projects above for a complete listing. You can also integrate all Manifold dependencies into your build using the “Fat” Jar dependency, manifold-all.

Setup instructions are consistent for each sub-project/dependency. Here are direct links:









Download

For the convenience of non-maven/non-gradle users you can directly download latest release binaries below. Note, if you plan to build your project without Maven or Gradle using select binaries (as opposed to manifold-all), your classpath must include the transitive closure of binaries in terms of the dependencies declared in corresponding project’s POM file. Additionally, you will need to adapt your build to reflect the Maven or Gradle setup instructions from the list above.









License

Open Source

Manifold is licensed under the Apache 2.0 license.

Commercial

Commercial licenses for this work are available. These replace the above ASL 2.0 and offer limited warranties, support, maintenance, and commercial server integrations.

For more information contact: admin@manifold.systems

Author