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 information and programming, a type manifold acts as an adapter to automatically connect a structured data source 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 structured data 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 source 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 resources 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.

Almost any type of data source imaginable is a potential type manifold. These include resource files, schemas, query languages, database definitions, templates, spreadsheets, web services, and programming languages.

Manifold provides type manifolds for:

More are in the works such as SQL, XML, and others.

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. Perhaps the most beneficial aspect of extensions, however, relate more to your overall experience with your development environment. For instance, code-completion conveniently presents all the extension methods available on an extended class:

There’s a lot more to the extension manifold including 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 .class files or .java targets to manage, no annotation processors, and no extra class loaders to engage at runtime.

Benefits of this approach include:

Additionally, 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 – IntelliJ IDEA

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 data source elements and find usages of them in your code. Watch your JSON/YAML, 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 Extension Libraries

Sample Projects

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