3

How do I create a static import using JavaPoet?

The code I'm trying to generate looks like this:

import static com.test.Types.*;
Dan
  • 9,681
  • 14
  • 55
  • 70
  • There is an open issue related to it: https://github.com/square/javapoet/issues/73 – andrucz Dec 07 '15 at 14:23
  • Cool - I did manage to work around it but the code isn't as pretty as it might be with a static import. – Dan Dec 07 '15 at 17:05

2 Answers2

5

For the record: static import is supported since 1.5.0

See JavaFileTest for example usages.

Sormuras
  • 8,491
  • 1
  • 38
  • 64
1

There is no way, but there is an open issue related to it: https://github.com/square/javapoet/issues/73

andrucz
  • 1,971
  • 2
  • 18
  • 30