Zurück zum Ranking

manifold-systems/manifold

Javamanifold.systems

Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.

javaintellijjsontemplate-enginereflection-frameworkextension-methodsstructural-typingduck-typingjava-toolingjava-developmenttype-providersmetaprogramming
Sterne-Wachstum
Sterne
2.8k
Forks
134
Wochenwachstum
Issues
104
1k2k
Okt. 2017Sept. 2020Aug. 2023Juli 2026
ArtefakteMavengit clone https://github.com/manifold-systems/manifold.git
README

latest chat GitHub Repo stars


What is Manifold?

Manifold is a Java compiler plugin. Use it to supplement your Java projects with highly productive features.

Advanced compile-time metaprogramming type-safely integrates any kind of data, metadata, or DSL directly into Java.

Powerful language enhancements improve developer productivity.

Each feature is available as a separate dependency. Simply add the Manifold dependencies of your choosing to your existing project and begin taking advantage of them.

All fully supported in JDK LTS releases 8 - 25 + latest with comprehensive IDE support in IntelliJ IDEA and Android Studio.

What's New...

Type-safe SQL

Manifold SQL lets you write native SQL directly and type-safely in your Java code.

  • Query types are instantly available as you type native SQL of any complexity in your Java code
  • Schema types are automatically derived from your database, providing type-safe CRUD, decoupled TX, and more
  • No ORM, No DSL, No wiring, and No code generation build steps



img_3.png

Who is using Manifold?

Sampling of companies using Manifold:

What can you do with Manifold?

Meta-programming

Use the framework to gain direct, type-safe access to any type of resource, such as SQL, JSON, GraphQL, XML, YAML, CSV, and even other languages such as JavaScript. Remove the code gen step in your build process.   Check it out!

SQL: Use native SQL of any complexity directly and type-safely from Java.

Language english =
  "[.sql/]select * from Language where name = 'English'".fetchOne();
Film film = Film.builder("My Movie", english)
  .withDescription("Nice movie")
  .withReleaseYear(2023)
  .build();
MyDatabase.commit();

GraphQL: Use types defined in .graphql files directly, no code gen steps! Make GraphQL changes and immediately use them with code completion.

var query = MovieQuery.builder(Action).build();
var result = query.request("http://com.example/graphql").post();
var actionMovies = result.getMovies();
for (var movie : actionMovies) {
  out.println(
    "Title: " + movie.getTitle() + "\n" +
    "Genre: " + movie.getGenre() + "\n" +
    "Year: " + movie.getReleaseDate().getYear() + "\n");
}

JSON: Use .json schema files directly and type-safely, no code gen steps! Find usages of .json properties in your Java code.

// From User.json
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!

manifold-parts

Favor composition over inheritance. Use @link and @part for automatic interface implementation forwarding and true 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
}

Properties

Eliminate boilerplate getter/setter code, 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, the feature automatically infers properties, both from your existing source files and from compiled classes your project uses. Reduce property use from this:

Actor person = result.getMovie().getLeadingRole().getActor();
Likes likes = person.getLikes();
likes.setCount(likes.getCount() + 1);

to this:

result.movie.leadingRole.actor.likes.count++;

Optional parameters & named arguments

Use optional parameters and named arguments with any Java project to add clarity and flexibility to call sites and as a refreshing alternative to method overloads and builders.

String valueOf(char[] data, 
               int offset = 0, 
               int count = data.length - offset) {...}

valueOf(array) // use defaults for offset and count
valueOf(array, 2) // use default for count
valueOf(array, count:20) // use default for offset by naming count

Binary compatible with methods, constructors, and records.

Operator Overloading

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

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

Tuple expressions

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

You can also use tuples with new auto type inference to enable multiple return values from a method.

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 try/catch/wrap/rethrow boilerplate!

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

String Templates

Inline 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";

A Java Template Engine

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>
<% for(User user: users) { %> 
  <% if(user.getDateOfBirth() != null) { %>
    User: ${user.getName()} <br>
    DOB: ${user.getDateOfBirth()} <br>
  <% } %>
<% } %>
</body>
</html>

IDE Support

Use the Manifold plugin to fully leverage Manifold with IntelliJ IDEA and Android Studio. The plugin provides comprehensive support for Manifold including code completion, navigation, usage searching, refactoring, incremental compilation, hotswap debugging, full-featured template editing, integrated preprocessor, and more.

manifold ij plugin

Get the plugin from JetBrains Marketplace

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 consists of one or more dependencies you can easily add to your project:

Manifold : Core

Manifold : Extensions

Manifold : Delegation

Manifold : Properties

Manifold : Optional parameters & named arguments

Manifold : Tuples

Manifold : SQL
Manifold : GraphQL
Manifold : JSON
Manifold : XML
Manifold : YAML
Manifold : CSV
Manifold : Property Files
Manifold : Image
Manifold : Dark Java
Manifold : JavaScript

Manifold : Java Templates

Manifold : String Interpolation
Manifold : (Un)checked Exceptions

Manifold : Preprocessor

Manifold : Science

Manifold : Collections
Manifold : I/0
Manifold : Text

Experiment with sample projects:

Platforms

Manifold supports:

Comprehensive IDE support is also available for IntelliJ IDEA and Android Studio.

Chat

Join our Discord server to start a discussion, ask questions, provide feedback, etc. Someone is usually there to help.


Ähnliche Repositories
CyC2018/CS-Notes

:books: 技术面试必备基础知识、Leetcode、计算机操作系统、计算机网络、系统设计

algorithmleetcode
cyc2018.xyz
184.8k50.8k
Snailclimb/JavaGuide

Java 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发

JavaScriptnpmApache License 2.0javainterview
javaguide.cn
157.2k46.2k
iluwatar/java-design-patterns

Design patterns implemented in Java

JavaMavenOtherjavaprinciples
java-design-patterns.com
94.2k27.4k
Stirling-Tools/Stirling-PDF

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

JavaMavenOtherdockerjava
stirling.com
87.7k7.8k
macrozheng/mall

mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于Spring Boot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。

JavaMavenApache License 2.0spring-bootspring-security
macrozheng.com/admin/
84.3k29.8k
spring-projects/spring-boot

Spring Boot helps you to create Spring-powered, production-grade applications and services with absolute minimum fuss.

JavaMavenApache License 2.0javaspring-boot
spring.io/projects/spring-boot
81.1k42k
doocs/advanced-java

😮 Core Interview Questions & Answers For Experienced Java(Backend) Developers | 互联网 Java 工程师进阶知识完全扫盲:涵盖高并发、分布式、高可用、微服务、海量数据处理等领域知识

JavaMavenCreative Commons Attribution Share Alike 4.0 Internationaljavadistributed-systems
java.doocs.org
79k19.2k
elastic/elasticsearch

Free and Open Source, Distributed, RESTful Search Engine

JavaMavenOtherelasticsearchjava
elastic.co/products/elasticsearch
77.6k26.1k
TheAlgorithms/Java

All Algorithms implemented in Java

JavaMavenMIT Licensejavaalgorithms
66k21.2k
kdn251/interviews

Everything you need to know to get the job.

JavaMavenMIT Licensejavainterview
youtube.com/channel/UCKvwPt6BifPP54yzH99ff1g
65.1k12.9k
youngyangyang04/leetcode-master

《代码随想录》LeetCode 刷题攻略:200道经典题目刷题顺序,共60w字的详细图解,视频难点剖析,50余张思维导图,支持C++,Java,Python,Go,JavaScript等多语言版本,从此算法学习不再迷茫!🔥🔥 来看看,你会发现相见恨晚!🚀

Shellleetcodeprogrammer
62k12.3k
azl397985856/leetcode

LeetCode Solutions: A Record of My Problem Solving Journey.( leetcode题解,记录自己的leetcode解题之路。)

JavaScriptnpmOtheralgorithmleetcode
leetcode-solution-leetcode-pp.gitbook.io/leetcode-solution/
55.8k9.4k