JavaPoetic

General

Category
Free
Tag
Instrumentation
License
Apache License, Version 2.0
Registered
Jul 17, 2015
Favorites
1
Link
https://github.com/yongjhih/JavaPoetic
See also
JavaPoet
adbi
Hook
javassist-android
ddi

Additional

Language
Java
Version
1.0.0 (Jul 14, 2015)
Created
May 30, 2015
Updated
Jul 17, 2015 (Retired)
Owner
Andrew Chen (yongjhih)
Contributors
Andrew Chen (yongjhih)
The Gitter Badger (gitter-badger)
2
Activity
Badge
Generate
Download
Source code

JavaPoetic

JavaPoet Simple Builder.

Square JavaPoet: https://github.com/square/javapoet

For JavaPoet example:

package com.example.helloworld;

public final class HelloWorld {
  public static void main(String[] args) {
    System.out.println("Hello, JavaPoet!");
  }
}

Before:

MethodSpec main = MethodSpec.methodBuilder("main")
    .addModifiers(Modifier.PUBLIC, Modifier.STATIC)
    .returns(void.class)
    .addParameter(String[].class, "args")
    .addStatement("$T.out.println($S)", System.class, "Hello, JavaPoet!")
    .build();

TypeSpec helloWorld = TypeSpec.classBuilder("HelloWorld")
    .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
    .addMethod(main)
    .build();

JavaFile javaFile = JavaFile.builder("com.example.helloworld", helloWorld)
    .build();

javaFile.emit(System.out);

After:

JavaFile javaFile = PoeticFile.Of.packages("com.example.helloworld").of(
            PoeticClass.Of.publics().classes("HelloWorld").method(
                PoeticMethod.Of.publics().statics().voids().name("main").parameter(String.class, "args").statement(
                    PoeticStatement.of("$T.out.println($S)", System.class, "Hello, JavaPoet!")
                )
            )
        );

javaFile.emit(System.out);

Installation

repositories {
    maven { url "https://jitpack.io" }
}

dependencies {
    compile 'com.github.yongjhih:javapoetic:-SNAPSHOT'
}

via jcenter:

repositories {
    jcenter()
}

dependencies {
    compile 'com.infstory:javapoetic:1.0.0'
}

Test

./gradlew test

License

Copyright 2015 8tory, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.