Skip to content

nbrugger-tgm/proto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Proto

Annotation Processor Tools

testcoverage

About

This is a collection of classes that helps with writing Java Annotation Processors. There are 3 min points this project provides

Usage

When writing an annotation processor the base class to use is BaseProcessor.

When doing so you will have two fields

  • logger
  • verifier

that provide high level access to the java processing API.

The bugfix mentioned above will automatically be applied to your project if you don' t disable it manually.

To generate classes it is highly recommended to use JavaPoet (included,Introduction to JavaPoet | Baeldung) and the writeClass() method.

Examples

verifier.isClass(someElement)
    .because("only classes can be mapped")
    .failOnViolation();

java: error someElement should be a class, because only classes can be mapped

verifier.isAnnotated(someElement, Override.class)
    .because("only overriden methods can be compile time mocked")
    .failOnViolation();

java: error someElement should be annotated with @Override, because only overriden methods can be compile time mocked

verifier.doesExtend(myElement, Serializable.class)
    .not()
    .because("Serializable is not state of the art")
    .warnOnViolation();

java: warning myElement should not extend Serializable, because Serializable is not state of the art

About

Annotation Processor Tools

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages