DEPRECATED
JSR 305 annotations are not compatible with the Java 9 module system. We recommend using Jetbrains' annotations artifact or (if on Android) the support library annotations.
javax-extras
Extra utilities for javax
Why a separate artifact?
Aside from reuse - the recommend scope to use this library in is compileOnly
or provided
. Modern tooling will recognize annotations in bytecode, and allows you to depend on this in a way that allows tooling to leverage it without bundling it as a part of your library/API.
Related reading: https://medium.com/square-corner-blog/non-null-is-the-default-58ffc0bb9111
What's available?
EverythingIsNonNullByDefault
- The nuclear option: Everything is NonNull by default. This includes method fields, method return types, method parameters, and local variables.
FieldsMethodsAndParametersAreNonNullByDefault
- This includes fields, method return types, and method parameters.
MethodsAndParametersAreNonNullByDefault
- This includes method return types and method parameters.
ParametersAreNonnullByDefault
- Is already in the jsr305 findbugs package this depends on. Use it :)
Others
We're open to suggestions! Feel free to open an issue or propose in a PR.
Proguard
As mentioned above, the recommended configuration for javax-extras annotations is compileOnly
or provided
scope. This can cause warning in proguard though. Our recommendation is to mark them as -dontwarn
, as the annotations are only CLASS
-retained and not in danger of runtime classloader issues.
-dontwarn com.uber.javaxextras.**
Download
compileOnly 'com.uber.javaxextras:javax-extras:x.y.z'
Snapshots of the development version are available in Sonatype's snapshots repository.
License
Copyright (C) 2017 Uber Technologies
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.