objectos :: code

Java source code abstraction. One API, many sources.

License

License

GroupId

GroupId

br.com.objectos
ArtifactId

ArtifactId

code
Last Version

Last Version

0.16.2
Release Date

Release Date

Type

Type

pom
Description

Description

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

Project Organization

Objectos Software LTDA

Download code

Filename Size
code-0.16.2.pom 4 KB
Browse

How to add to project

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

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • code-apt
  • code-core
  • code-it
  • code-jdt
  • code-testing
  • code-tools
  • code-tools-testing

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