Merge branch 'stable-2.14' into stable-2.15
* stable-2.14: FormatUtil: Correctly fix the Math#round() error flagged by error-prone Add a change deleted event/listener Fix broken link in documentation of receive.requireSignedPush Change-Id: I354180a7850bb7af28a20306e9b5db67b3a92bbd
This commit is contained in:
@@ -137,25 +137,7 @@ public class FormatUtil {
|
||||
if (size == 0) {
|
||||
return Resources.C.notAvailable();
|
||||
}
|
||||
int p = Math.abs(saturatedCast(delta * 100 / size));
|
||||
return p + "%";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@code int} nearest in value to {@code value}.
|
||||
*
|
||||
* @param value any {@code long} value
|
||||
* @return the same value cast to {@code int} if it is in the range of the {@code int} type,
|
||||
* {@link Integer#MAX_VALUE} if it is too large, or {@link Integer#MIN_VALUE} if it is too
|
||||
* small
|
||||
*/
|
||||
private static int saturatedCast(long value) {
|
||||
if (value > Integer.MAX_VALUE) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
if (value < Integer.MIN_VALUE) {
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
return (int) value;
|
||||
long percentage = Math.abs(Math.round(delta * 100.0 / size));
|
||||
return percentage + "%";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user