An open API service indexing awesome lists of open source software.

https://github.com/code4craft/forger

Dynamic Java object generator with template class and configuration.
https://github.com/code4craft/forger

Last synced: 9 months ago
JSON representation

Dynamic Java object generator with template class and configuration.

Awesome Lists containing this project

README

          

forger
======

Dynamic Java object generator with template class and configuration.

## Compiler

Use groovy compiler. Compile source code to Java class.

## PropertyLoader

Load properties of object from user input.

## API

```java
@Test
public void testForgerCreateByClassAnnotationCompile() throws Exception {
ForgerFactory forgerFactory = new ForgerFactory(new AnnotationPropertyLoader(), new GroovyForgerCompiler());
Forger forger = forgerFactory.compile(Foo.SOURCE_CODE);
Fooable foo = forger.forge(ImmutableMap.of("fooa", "test"));
Field field = forger.getClazz().getDeclaredField("foo");
field.setAccessible(true);
assertThat(field.get(foo)).isEqualTo("test");
assertThat(foo.foo()).isEqualTo("test");
}
```