Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/annimon-tutorials/javac-plugin-demo
Source code for tutorial
https://github.com/annimon-tutorials/javac-plugin-demo
extension-methods javac operator-overloading plugin
Last synced: 1 day ago
JSON representation
Source code for tutorial
- Host: GitHub
- URL: https://github.com/annimon-tutorials/javac-plugin-demo
- Owner: annimon-tutorials
- License: mit
- Created: 2017-03-22T19:26:35.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-22T19:28:06.000Z (almost 8 years ago)
- Last Synced: 2023-10-27T21:31:39.567Z (about 1 year ago)
- Topics: extension-methods, javac, operator-overloading, plugin
- Language: Java
- Homepage: https://annimon.com/article/2626
- Size: 68.4 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Javac Plugin Demo
## CharStat
Calculates number of characters of the compiled source code.
## MethodsCount
Calculates methods count per source file and outputs overall methods count.
## MapAccess
Allows to access the `Map` with string literal key as the array:
```java
Map map = new HashMap<>();
map["key"] = "ten"; // map.put("key", "ten")
System.out.println(map["key"]); // map.get("key")
```## OperatorOverloading
Overloads `+ - * /` operators to map to `add subtract multiply divide` methods.
```java
BigInteger x1 = BigInteger.TEN;
BigInteger x2 = BigInteger.valueOf(120);
BigInteger x3 = x1 + x2;
// BigInteger x3 = x1.add(x2);
BigInteger x4 = BigInteger.valueOf(2) * x3;
// BigInteger x4 = BigInteger.valueOf(2).multiply(x3);
BigInteger x5 = x4 - x2 / x1 + x3;
// BigInteger x5 = x4.subtract(x2.divide(x1)).add(x3);
```## ExtensionMethods
Allows to use extension methods. The extension method should be declared as `public static` in the same class.
```java
public static IntStream filterNot(IntStream stream, IntPredicate predicate) {
return stream.filter(predicate.negate());
}public static > Stream sortBy(Stream stream, Function super T, ? extends R> f) {
return stream.sorted((o1, o2) -> f.apply(o1).compareTo(f.apply(o2)));
}apps.stream()
.filterNot(Application::isInstalled)
.sortBy(Application::getDownloadingTime())
```