objectos :: code :: apt

Java source code abstraction. One API, many sources.

License

License

GroupId

GroupId

br.com.objectos
ArtifactId

ArtifactId

code-apt
Last Version

Last Version

0.16.2
Release Date

Release Date

Type

Type

jar
Description

Description

objectos :: code :: apt
Java source code abstraction. One API, many sources.
Project Organization

Project Organization

Objectos Software LTDA

Download code-apt

How to add to project

<!-- https://jarcasting.com/artifacts/br.com.objectos/code-apt/ -->
<dependency>
    <groupId>br.com.objectos</groupId>
    <artifactId>code-apt</artifactId>
    <version>0.16.2</version>
</dependency>
// https://jarcasting.com/artifacts/br.com.objectos/code-apt/
implementation 'br.com.objectos:code-apt:0.16.2'
// https://jarcasting.com/artifacts/br.com.objectos/code-apt/
implementation ("br.com.objectos:code-apt:0.16.2")
'br.com.objectos:code-apt:jar:0.16.2'
<dependency org="br.com.objectos" name="code-apt" rev="0.16.2">
  <artifact name="code-apt" type="jar" />
</dependency>
@Grapes(
@Grab(group='br.com.objectos', module='code-apt', version='0.16.2')
)
libraryDependencies += "br.com.objectos" % "code-apt" % "0.16.2"
[br.com.objectos/code-apt "0.16.2"]

Dependencies

compile (3)

Group / Artifact Type Version
br.com.objectos : code-core jar 0.16.2
br.com.objectos : collections jar 0.2.1
br.com.objectos.lazy : api jar 0.5.0

test (1)

Group / Artifact Type Version
br.com.objectos : assertion jar 0.7.0

Project Modules

There are no modules declared in this project.

ObjectosCode

Java source code generation and annotation processing library.

Build Status Maven Central GitHub license

Example

The following code:

PackageName examplesPackage = PackageName.named("br.com.objectos.code.examples");
ClassName helloWorld = examplesPackage.nestedClass("HelloWorld");
Identifier obj = id("obj");

MethodCode mainMethod = method(
    _public(), _static(), _void(), id("main"),
    param(a(cn(String.class)), id("args")),

    _var(helloWorld, obj, _new(helloWorld)),
    invoke(obj, "sayHello")
);

MethodCode sayHelloMethod = method(
    _public(), _final(), _void(), id("sayHello"),
    cn(System.class).id("out").invoke("println", invoke("helloMessage"))
);

MethodCode helloMessageMethod = method(
    _private(), cn(String.class), id("helloMessage"),
    _return(l("Hello world!"))
);

ClassCode helloWorldClass = _class(
    _public(), _final(), id("HelloWorld"),
    mainMethod,
    sayHelloMethod,
    helloMessageMethod
);

JavaFile helloWorldFile = javaFile(
    examplesPackage,
    helloWorldClass
);

System.out.println(helloWorldFile.toString());

produces the following output:

package br.com.objectos.code.examples;

public final class HelloWorld {
  
  public static void main(String[] args) {
    HelloWorld obj = new HelloWorld();
    obj.sayHello();
  }
  
  public final void sayHello() {
    System.out.println(helloMessage());
  }

  private String helloMessage() {
    return "Hello world!";
  }

}

Documentation

A proper documentation is on the way.

In the meantime you can browse some examples here.

Maven

objectos::code is at Maven Central.

<dependency>
	<groupId>br.com.objectos.code</groupId>
	<artifactId>code</artifactId>
	<version>0.29.1</version>
</dependency>

License

Copyright (C) 2014-2020 Objectos Software LTDA

Licensed under the GNU Affero General Public License v3.

Notice

This library includes code from other open-source projects. See attached NOTICE.txt.

br.com.objectos

Objectos Software

We craft Java tools.

Versions

Version
0.16.2
0.16.1
0.16.0
0.8.2
0.8.1
0.8.0
0.7.0
0.6.0
0.5.0
0.4.11
0.4.10
0.4.9
0.4.8
0.4.7
0.4.6
0.4.5
0.4.4
0.4.3
0.4.2
0.4.1
0.4.0
0.3.0
0.2.0
0.1.2
0.1.1
0.1.0