J. *_* K. 4 java android annotations
我读了这篇文章今天在Android Studio支持注释上,并开始在我的代码中使用这些注释,这是一个例子:
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;
}
..
}
Run Code Online (Sandbox Code Playgroud)
在我的代码中,我有一个接受double它的构造函数中的值的类,但是没有@DoubleRange注释.我使用@FloatRange还是什么都没有?long值相同的问题
实际上,@ FloatRange的文档说明:
Denotes that the annotated element should be a float or double in the given range
Run Code Online (Sandbox Code Playgroud)
和@IntRange类似的情况
Denotes that the annotated element should be an int or long in the given range
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
472 次 |
| 最近记录: |