项目作者: annimon-tutorials

项目描述 :
Source code for tutorial
高级语言: Java
项目地址: git://github.com/annimon-tutorials/Javac-Plugin-Demo.git
创建时间: 2017-03-22T19:26:35Z
项目社区:https://github.com/annimon-tutorials/Javac-Plugin-Demo

开源协议:MIT License

下载


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:

  1. Map<String, String> map = new HashMap<>();
  2. map["key"] = "ten"; // map.put("key", "ten")
  3. System.out.println(map["key"]); // map.get("key")

OperatorOverloading

Overloads + - * / operators to map to add subtract multiply divide methods.

  1. BigInteger x1 = BigInteger.TEN;
  2. BigInteger x2 = BigInteger.valueOf(120);
  3. BigInteger x3 = x1 + x2;
  4. // BigInteger x3 = x1.add(x2);
  5. BigInteger x4 = BigInteger.valueOf(2) * x3;
  6. // BigInteger x4 = BigInteger.valueOf(2).multiply(x3);
  7. BigInteger x5 = x4 - x2 / x1 + x3;
  8. // 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.

  1. public static IntStream filterNot(IntStream stream, IntPredicate predicate) {
  2. return stream.filter(predicate.negate());
  3. }
  4. public static <T, R extends Comparable<? super R>> Stream<T> sortBy(Stream<T> stream, Function<? super T, ? extends R> f) {
  5. return stream.sorted((o1, o2) -> f.apply(o1).compareTo(f.apply(o2)));
  6. }
  7. apps.stream()
  8. .filterNot(Application::isInstalled)
  9. .sortBy(Application::getDownloadingTime())