I read this article on Android Studio Support Annotations today and started using these annotations in my code, here is an example:
public final static class GoogleMapsZoomLevel {
public static final int MIN_ZOOM_LEVEL = 0;
public static final int MAX_ZOOM_LEVEL = 21;
..
public GoogleMapsZoomLevel(@IntRange(from=MIN_ZOOM_LEVEL, to=MAX_ZOOM_LEVEL) int zoomLevel) {
if (zoomLevel < MIN_ZOOM_LEVEL || zoomLevel > MAX_ZOOM_LEVEL) {
throw new IllegalArgumentException(ERROR_ZOOM_LEVEL_OUT_OF_BOUNDS);
}
this.zoomLevel = zoomLevel;
}
..
}
Further down in my code I have a class that accepts double
values in it's constructor, but there is no @DoubleRange annotation. Do I use @FloatRange or nothing at all? Same question for long
values