Skip to content

Instantly share code, notes, and snippets.

@edefazio
Last active February 8, 2017 17:58
Show Gist options
  • Save edefazio/f1bed02ff66524149c215311c6d6f356 to your computer and use it in GitHub Desktop.
Save edefazio/f1bed02ff66524149c215311c6d6f356 to your computer and use it in GitHub Desktop.
varcode build model of annotation type example
package usecase.model;
import varcode.java.adhoc.Export;
import varcode.java.model._annotationType;
public class ModelAnnotationType
{
static _annotationType _ModelOfAnnotation = _annotationType.of(
"package usecase.model;",
"import java.lang.annotation.Retention;",
"import java.lang.annotation.RetentionPolicy;",
"/** Annotation Type Javadoc comment */",
"@Retention(RetentionPolicy.RUNTIME)",
"public @interface ModelOfAnnotation" )
.property( "float", "price" )
.property( "boolean", "isOpen" )
//properties with defaults
.property( "int", "count", 1 )
.property( String.class, "property", "\"defaultValue\"" )
.property( String[].class, "arrayString", "{\"A\", \"B\"}" );
public static void main( String[] args )
{
System.out.println( _ModelOfAnnotation );
Export.dir( "C:\\MyApp\\src\\main\\java\\" ).toFile( _ModelOfAnnotation );
Class clazz = _ModelOfAnnotation.loadClass();
Export.dir( "C:\\MyApp\\target\\classes\\" ).toFile( clazz );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment