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:
David Pursehouse
2018-09-16 09:29:19 +09:00
13 changed files with 196 additions and 25 deletions

View File

@@ -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 + "%";
}
}