Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using Java requireNonNull instead of Guava checkNotNull in generated code #129

Closed
gaul opened this issue Jul 11, 2015 · 4 comments
Labels

Comments

@gaul
Copy link

gaul commented Jul 11, 2015

checkNotNull triggers Modernizer violations in generated code: gaul/modernizer-maven-plugin#28. Immutables already requires Java 7 so generated code can use requireNonNull.

@elucash
Copy link
Member

elucash commented Jul 12, 2015

Thank you for reporting the issue!
Immutables able to generate JDK only code, including mentioned requireNonNull. In order to do this either of the following should be true:

  • There is no Guava on the class-path
  • Or style set to force jdk only mode: @Value.Style(jdkOnly = true, ...). (see guide on how to apply styles)

Please check if you can apply any of the above.
If there need to mostly use Guava in generated code as it is, but to have requireNonNull or other goodies to replace guava's ones, then we could discuss complete set of API or other workarounds.

@gaul
Copy link
Author

gaul commented Jul 12, 2015

@talios Does using JDK-only code address your issue?

@talios
Copy link

talios commented Jul 15, 2015

@andrewgaul Just noticed this - is that a new setting or has it been there for awhile? Seems to work a treat cheers!

@elucash
Copy link
Member

elucash commented Jul 15, 2015

it's one of the main new features in 2.0: Guava is no longer a required dependency, albeit still fully supported if present. jdkOnly setting is to force usage of JDK only utilities as classpath may just contain Guava even if you don't want to use it in a generated code (and still if you use explicit ImmutableList from guava, for example, it should work as expected).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants