Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.
Tuple expressions provide concise syntax to group named data items in a lightweight structure.
var t = (name: "Bob", age: "35");
System.out.println("Name: " + t.name + " Age: " + t.age);
var t = (person.name, person.age);
System.out.println("Name: " + t.name + " Age: " + t.age);
Favor composition over inheritance. Use @link
and @part
for automatic interface implementation forwarding and delegation.
class MyClass implements MyInterface {
@link MyInterface myInterface; // transfers calls on MyInterface to myInterface
public MyClass(MyInterface myInterface) {
this.myInterface = myInterface; // dynamically configure behavior
}
// No need to implement MyInterface here, but you can override myInterface as needed
}
auto
type inferenceauto
type inference for local vars, fields, and method return typesimport manifold.ext.rt.api.auto;
var result = findMinMax(data);
System.out.println("Minimum: " + result.min + " Maximum: " + result.max);
auto findMinMax(int[] data) {
if(data == null || data.length == 0) return null;
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
for(int i: data) {
if(i < min) min = i;
if(i > max) max = i;
}
return min, max;
}
#536: manifold-graphql: override java-graphql ParserOptions which are not applicable to compile-time use e.g., maxTokens
#535: Intellij plugin: suppress "non-final field 'x' in enum..." issues re @val
usage
#533: Intellij plugin: suppress false positive errors re manifold string templates
#532: Intellij plugin: string template processing is disabled in annotations due to wide usage of ${} templating in many annotation libraries
#531: Fix ProcessCanceledExceptions, forward exceptions directly during "slow operations" handling, esp. ProcessCanceledException
#529: Suppress error/warning messages in Chinese as well as English, translate/map message filters to Chinese (Simplified) Language Pack.
#528: Use private tags to execute "slow operations", centralize how/where these are executed
#525: Preprocessor: Enable IDE to use SymbolProviders according to module dependencies
#520: Provide error message when attempting to use a method ref for a method returning auto
, must use lambda in this case (for now)
#516: Fix NoClassDefFoundError: com/intellij/lang/java/parser/BasicStatementParser (affected IJ versions: 2023.2.2, 2023.2.3)
#497: IntelliJ plugin: Complete JDK 21 support
#495: IntelliJ plugin: Improve performance and stability of manifold fragments in IntelliJ
#494: IntelliJ plugin: Fix fragment error reporting
#489: Fix "cannot implement" interface error using delegation with @link
in JDK 21
#488: Fix tuple expr passed directly as argument to method (was broken in jdk 11+)
#483: Unintended behavior for manifold-prop annotation parameters
#479: Unintended behavior when using both manifold-delegation and manifold-props
#478: Support abstract enum methods with manifold-ext
#477: Field access from inside the class on a @set
field
#476: Fix issue with using annotation processors e.g., lombok, mixed with manifold
#474: Fix regression in 2023.1.15 where new fragment delimiters can interfere with string templates
#473: Change fragment delimiters
#471: Change return type to be compatible with SequencedCollection#reversed
#470: Support "short" runtime methods
#468: Avoid adding bootstrap block to sidecar classes
#467: IntelliJ plugin: support error/warning highlights in fragments (in prep for manifold-sql)
#466: IntelliJ plugin: Deprecated class usage results in compilation error in IntelliJ IDEA
#451: IntelliJ plugin: Invalid warning message re older manifold version in project than in intellij plugin
#449: Remedy a java symbol resolve issue where a field and an inner class share the same name
#446: Use MathContext.128 for big decimal division
#436: Fix mapstruct handling of default interface methods
#422: Fix self type bug with arrays
#423: Add support for forwarding and delegation
#421: IntelliJ plugin: auto, like var, should be highlighted as a keyword
#418: Compiling from IntelliJ can cause UnsupportedClassVersionError using the preprocessor and using pre-JDK 17
#417: Class cannot be converted Issue
#416: Unqualified static varargs extension method call results in compiler error
#414: Using JDK 17+ in preview mode + using an annotation processor causes NPE
#412: "Variable expected" error involving multidimensional index operator in assignment
#411: Intermittent "Incorrect CachedValue use" errors
#400: Support getter/setter extension methods as property access for manifold-props
#409: Intellij plugin: fix generic extension method type parameter inference regression
#408: Support Valhalla EA Jdk releases
#407: Fix compile error using latest JDK 20 EA release (build 28)
#406: IntelliJ plugin: "Incorrect CachedValue use:" errors reported with property and extension caching
#405: IntelliJ plugin: many issues in latest 2022.3 release with renaming files/elements, other related issues
#404: Using ReflectUtil with JDK 19 cannot set value on static final field on an interface
#403: Extension methods on inner classes not working in some cases
#402: IntelliJ plugin: Exception when using tuple expressions without adding manifold-tuple/manifold-tuple-rt
#396: Handle expression in foreach stmt where the expression type structurally implements Iterator and a class extension exists that makes Iterable structural
#395: Support property inference on record types
#394: Support EA release of JDK 20
#393: Java 17+: fix $ escape char for string templates
#392: Cast as raw generic type
#387: Tree is null for module-info file, do not process
#380: Fix regression involving fields as structurally equivalent to get/set methods
#382: Fix instanceof pattern matching issue related to parser changes in latest IntelliJ release
#376: Support an explicit typed variable having an implicit typed initializer expression
#375: Policy change: support only LTS versions of JDKs and the latest release
#373: New Feature: multiple return types via auto
and enhanced tuple expressions
#372: New Feature: type-safe tuple expressions
#371: New Feature: auto
type inference for local vars, fields, and method return types
#364: Add @Expires
annotation to prevent extension methods from duplicating JDK methods
#355: fix instanceof Pattern Matching within if-statement condition (Cannot Find Symbol)
#351: Increment/decrement operators on properties cause compiler exception in Java 11+
#349: Support non-public extension methods
#348: @ThisClass
extension method receiver, provides the calling class of static method
#345: Allow Jailbreak to work when casting
SymbolProvider
SPI to augment the environment definitions with your own custom environment symbols.The manifold-preprocessor-android-syms
library implements the service to provide direct access to
Android build variant symbols. You can add the library as a dependency to gain automatic access to familiar Android
BuildConfig
symbols:
DEBUG
BUILD_TYPE // current build variant
FLAVOR // flavor of current build variant
etc.
See manifold-preprocessor-android-syms for details.
Manifold integrates directly with the Java parser, as such there are no intermediate files to manage. However,
some tools may need to parse or otherwise analyze processed Java source separate from the Java compiler. In this case
you can use the manifold.source.target
compiler option to specify a directory where all source is copied as it is
compiled, including preprocessed and generated source from Manifold.
Usage:
javac -Amanifold.source.target=<my-directory> ...
-Xlint:all
usage$foo
syntax from processing while still allowing ${foo}
The manifold-props
project is a compiler plugin to simplify declaring and using properties in Java. Use it to reduce
the amount of code you would otherwise write and to improve your overall dev experience with properties.
public interface Book {
@var String title; // no more boilerplate code!
}
// refer to it directly by name
book.title = "Daisy"; // calls setter
String name = book.title; // calls getter
book.title += " chain"; // calls getter & setter
Additionally, manifold-props
automatically infers properties, both from your existing source files and from
compiled classes your project uses.
java.time.ZonedDateTime zdt = ZonedDateTime.now();
String calendarType = zdt.chronology.calendarType; // access properties concisely & consistently throughout yor project
See Property inference.
Properties are fully integrated in both IntelliJ IDEA and Android Studio. Use the IDE's features to create new properties, verify property references, access properties with code completion, and more.
++
and --
+=
, -=
, *=
, /=
, %=
,[]
, both access and assignmentPlease see Operator Overloading documentation for details.
New and
binding constant:
Pair
class to simplify syntax:Pair<String, Integer> pair = "Moe" and 100;
Map#mapOf
extension method:Map<String, Integer> scores = mapOf("Moe" and 100, "Larry" and 107, "Curly" and 111);
Manifold now fully supports Android Studio. Please see Android Setup to learn more.
Use Manifold with Kotlin and other JVM languages! Please see Kotlin Support to learn more.
Manifold now supports Java -source
and -target
versions prior to 8 with core features and most extensions including
manifold-preprocessor.
For instance, using manifold-preprocessor you can use builtin definitions like this:
#if JAVA_6
public String perform() {
return "java6";
}
#elif JAVA_7
public String perform() {
return "java7";
}
#elif JAVA_8_OR_LATER
public String perform() {
return "at least java8";
}
#endif
Notes:
- Although Manifold supports -source and -target levels below 8, you must use a Java 8 or later compiler in your build
- Some type manifolds such as manifold-graphql and manifold-json are not supported with -source levels below 8
Manifold dependencies are now separated into compile-only and API (or implementation) modules. This change allows projects to limit Manifold's compilation features to compile-time and eliminate most of Manifold's footprint from runtime. This change is also at the heart of Manifold's support for Android and Kotlin.
Similar to javac's source file list, Manifold provides -Amanifold.source.<ext>=<regex>
javac command line options to
explicitly compile resources either by type name using regular expressions or by file name using file system paths.
See the Sample Kotlin App for an example of using explicit resource compilation.
Comprehensive support for CSV, interchangeable with JSON, XML, and YAML.
// Type-safely use a CSV file in your resource directory, no code gen
import com.example.MyCsvData; // from resource file: com/example/MyCsvData.csv
import com.example.MyCsvData.MyCsvDataItem;
...
// Load data from the resource file
MyCsvData dataItems = MyCsvData.fromSource();
// Access rows of data type-safely
for (MyCsvData.MyCsvDataItem item: dataItems) {
String name = item.getLastName();
LocalDateTime startDate = item.getStartDate();
...
}
Comprehensive support for XML, interchangeable with JSON, YAML, and CSV.
// Type-safely use an XML file in your resource directory
import com.example.config.MyXmlConfig;
...
// Load data from the resource file
MyXmlConfig config = MyXmlConfig.fromSource();
// Access elements/attributes type-safely
var linesOfBusiness = config.getEnvironment().getLinesOfBusiness();
...
Implement operator methods on any type to directly support arithmetic, relational, and unit operators.
// BigDecimal expressions
if (bigDec1 > bigDec2) {
BigDecimal result = bigDec1 + bigDec2;
...
}
// Implemnet operators for any type
MyType value = myType1 + myType2;
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;
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);
}
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;
The manifold-props
project is a compiler plugin to simplify declaring and using properties in Java. Use it to reduce
the amount of code you would otherwise write and to improve your overall dev experience with properties.
public interface Book {
@var String title; // no more boilerplate code!
}
// refer to it directly by name
book.title = "Daisy"; // calls setter
String name = book.title; // calls getter
book.title += " chain"; // calls getter & setter
Additionally, manifold-props
automatically infers properties, both from your existing source files and from
compiled classes your project uses.
java.time.ZonedDateTime zdt = ZonedDateTime.now();
String calendarType = zdt.chronology.calendarType; // access properties concisely & consistently throughout yor project
See Property inference.
Properties are fully integrated in both IntelliJ IDEA and Android Studio. Use the IDE's features to create new properties, verify property references, access properties with code completion, and more.
++
and --
+=
, -=
, *=
, /=
, %=
,[]
, both access and assignmentPlease see Operator Overloading documentation for details.
New and
binding constant:
Pair
class to simplify syntax:Pair<String, Integer> pair = "Moe" and 100;
Map#mapOf
extension method:Map<String, Integer> scores = mapOf("Moe" and 100, "Larry" and 107, "Curly" and 111);
Manifold now fully supports Android Studio. Please see Android Setup to learn more.
Use Manifold with Kotlin and other JVM languages! Please see Kotlin Support to learn more.
Manifold now supports Java -source
and -target
versions prior to 8 with core features and most extensions including
manifold-preprocessor.
For instance, using manifold-preprocessor you can use builtin definitions like this:
#if JAVA_6
public String perform() {
return "java6";
}
#elif JAVA_7
public String perform() {
return "java7";
}
#elif JAVA_8_OR_LATER
public String perform() {
return "at least java8";
}
#endif
Notes:
- Although Manifold supports -source and -target levels below 8, you must use a Java 8 or later compiler in your build
- Some type manifolds such as manifold-graphql and manifold-json are not supported with -source levels below 8
Manifold dependencies are now separated into compile-only and API (or implementation) modules. This change allows projects to limit Manifold's compilation features to compile-time and eliminate most of Manifold's footprint from runtime. This change is also at the heart of Manifold's support for Android and Kotlin.
Similar to javac's source file list, Manifold provides -Amanifold.source.<ext>=<regex>
javac command line options to
explicitly compile resources either by type name using regular expressions or by file name using file system paths.
See the Sample Kotlin App for an example of using explicit resource compilation.
Comprehensive support for CSV, interchangeable with JSON, XML, and YAML.
// Type-safely use a CSV file in your resource directory, no code gen
import com.example.MyCsvData; // from resource file: com/example/MyCsvData.csv
import com.example.MyCsvData.MyCsvDataItem;
...
// Load data from the resource file
MyCsvData dataItems = MyCsvData.fromSource();
// Access rows of data type-safely
for (MyCsvData.MyCsvDataItem item: dataItems) {
String name = item.getLastName();
LocalDateTime startDate = item.getStartDate();
...
}
Comprehensive support for XML, interchangeable with JSON, YAML, and CSV.
// Type-safely use an XML file in your resource directory
import com.example.config.MyXmlConfig;
...
// Load data from the resource file
MyXmlConfig config = MyXmlConfig.fromSource();
// Access elements/attributes type-safely
var linesOfBusiness = config.getEnvironment().getLinesOfBusiness();
...
Implement operator methods on any type to directly support arithmetic, relational, and unit operators.
// BigDecimal expressions
if (bigDec1 > bigDec2) {
BigDecimal result = bigDec1 + bigDec2;
...
}
// Implemnet operators for any type
MyType value = myType1 + myType2;
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;
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);
}
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;
Manifold now fully supports Android Studio. Please see Android Setup to learn more.
Use Manifold with Kotlin and other JVM languages! Please see Kotlin Support to learn more.
Manifold now supports Java -source
and -target
versions prior to 8 with core features and most extensions including
manifold-preprocessor.
For instance, using manifold-preprocessor you can use builtin definitions like this:
#if JAVA_6
public String perform() {
return "java6";
}
#elif JAVA_7
public String perform() {
return "java7";
}
#elif JAVA_8_OR_LATER
public String perform() {
return "at least java8";
}
#endif
Notes:
- Although Manifold supports -source and -target levels below 8, you must use a Java 8 or later compiler in your build
- Some type manifolds such as manifold-graphql and manifold-json are not supported with -source levels below 8
Manifold dependencies are now separated into compile-only and API (or implementation) modules. This change allows projects to limit Manifold's compilation features to compile-time and eliminate most of Manifold's footprint from runtime. This change is also at the heart of Manifold's support for Android and Kotlin.
Similar to javac's source file list, Manifold provides -Amanifold.source.<ext>=<regex>
javac command line options to
explicitly compile resources either by type name using regular expressions or by file name using file system paths.
See the Sample Kotlin App for an example of using explicit resource compilation.
Comprehensive support for CSV, interchangeable with JSON, XML, and YAML.
// Type-safely use a CSV file in your resource directory, no code gen
import com.example.MyCsvData; // from resource file: com/example/MyCsvData.csv
import com.example.MyCsvData.MyCsvDataItem;
...
// Load data from the resource file
MyCsvData dataItems = MyCsvData.fromSource();
// Access rows of data type-safely
for (MyCsvData.MyCsvDataItem item: dataItems) {
String name = item.getLastName();
LocalDateTime startDate = item.getStartDate();
...
}
Comprehensive support for XML, interchangeable with JSON, YAML, and CSV.
// Type-safely use an XML file in your resource directory
import com.example.config.MyXmlConfig;
...
// Load data from the resource file
MyXmlConfig config = MyXmlConfig.fromSource();
// Access elements/attributes type-safely
var linesOfBusiness = config.getEnvironment().getLinesOfBusiness();
...
Implement operator methods on any type to directly support arithmetic, relational, and unit operators.
// BigDecimal expressions
if (bigDec1 > bigDec2) {
BigDecimal result = bigDec1 + bigDec2;
...
}
// Implemnet operators for any type
MyType value = myType1 + myType2;
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;
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);
}
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;
Manifold now fully supports Android Studio. Please see Android Setup to learn more.
Use Manifold with Kotlin and other JVM languages! Please see Kotlin Support to learn more.
Manifold now supports Java -source
and -target
versions prior to 8 with core features and most extensions including
manifold-preprocessor.
For instance, using manifold-preprocessor you can use builtin definitions like this:
#if JAVA_6
public String perform() {
return "java6";
}
#elif JAVA_7
public String perform() {
return "java7";
}
#elif JAVA_8_OR_LATER
public String perform() {
return "at least java8";
}
#endif
Notes:
- Although Manifold supports -source and -target levels below 8, you must use a Java 8 or later compiler in your build
- Some type manifolds such as manifold-graphql and manifold-json are not supported with -source levels below 8
Manifold dependencies are now separated into compile-only and API (or implementation) modules. This change allows projects to limit Manifold's compilation features to compile-time and eliminate most of Manifold's footprint from runtime. This change is also at the heart of Manifold's support for Android and Kotlin.
Similar to javac's source file list, Manifold provides -Amanifold.source.<ext>=<regex>
javac command line options to
explicitly compile resources either by type name using regular expressions or by file name using file system paths.
See the Sample Kotlin App for an example of using explicit resource compilation.
Comprehensive support for CSV, interchangeable with JSON, XML, and YAML.
// Type-safely use a CSV file in your resource directory, no code gen
import com.example.MyCsvData; // from resource file: com/example/MyCsvData.csv
import com.example.MyCsvData.MyCsvDataItem;
...
// Load data from the resource file
MyCsvData dataItems = MyCsvData.fromSource();
// Access rows of data type-safely
for (MyCsvData.MyCsvDataItem item: dataItems) {
String name = item.getLastName();
LocalDateTime startDate = item.getStartDate();
...
}
Comprehensive support for XML, interchangeable with JSON, YAML, and CSV.
// Type-safely use an XML file in your resource directory
import com.example.config.MyXmlConfig;
...
// Load data from the resource file
MyXmlConfig config = MyXmlConfig.fromSource();
// Access elements/attributes type-safely
var linesOfBusiness = config.getEnvironment().getLinesOfBusiness();
...
Implement operator methods on any type to directly support arithmetic, relational, and unit operators.
// BigDecimal expressions
if (bigDec1 > bigDec2) {
BigDecimal result = bigDec1 + bigDec2;
...
}
// Implemnet operators for any type
MyType value = myType1 + myType2;
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;
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);
}
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;
Comprehensive support for CSV, interchangeable with JSON, XML, and YAML.
// Type-safely use a CSV file in your resource directory, no code gen
import com.example.MyCsvData; // from resource file: com/example/MyCsvData.csv
import com.example.MyCsvData.MyCsvDataItem;
...
// Load data from the resource file
MyCsvData dataItems = MyCsvData.fromSource();
// Access rows of data type-safely
for (MyCsvData.MyCsvDataItem item: dataItems) {
String name = item.getLastName();
LocalDateTime startDate = item.getStartDate();
...
}
Comprehensive support for XML, interchangeable with JSON, YAML, and CSV.
// Type-safely use an XML file in your resource directory
import com.example.config.MyXmlConfig;
...
// Load data from the resource file
MyXmlConfig config = MyXmlConfig.fromSource();
// Access elements/attributes type-safely
var linesOfBusiness = config.getEnvironment().getLinesOfBusiness();
...
Implement operator methods on any type to directly support arithmetic, relational, and unit operators.
// BigDecimal expressions
if (bigDec1 > bigDec2) {
BigDecimal result = bigDec1 + bigDec2;
...
}
// Implemnet operators for any type
MyType value = myType1 + myType2;
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;
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);
}
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;
Implement operator methods on any type to directly support arithmetic, relational, and unit operators.
// BigDecimal expressions
if (bigDec1 > bigDec2) {
BigDecimal result = bigDec1 + bigDec2;
...
}
// Implemnet operators for any type
MyType value = myType1 + myType2;
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;
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);
}
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;