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.
- Host: GitHub
- URL: https://github.com/code4craft/forger
- Owner: code4craft
- License: apache-2.0
- Created: 2014-02-25T06:44:25.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-03-15T10:56:33.000Z (almost 12 years ago)
- Last Synced: 2023-12-20T08:48:51.967Z (about 2 years ago)
- Language: Java
- Size: 234 KB
- Stars: 3
- Watchers: 4
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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");
}
```