[guava-libraries] 02/04: Restored the Stopwatch methods and constructors

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Fri Jul 3 17:54:52 UTC 2015


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to branch master
in repository guava-libraries.

commit 475ff39b0af94b1abd700ebd17267ab7452e1251
Author: Emmanuel Bourg <ebourg at apache.org>
Date:   Fri Jul 3 09:27:32 2015 +0200

    Restored the Stopwatch methods and constructors
---
 debian/changelog                                   |  2 +
 debian/patches/09-preserve-stopwatch-methods.patch | 97 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 3 files changed, 100 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 8a9f5c1..afdd7fc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,8 @@ guava-libraries (18.0-3) UNRELEASED; urgency=medium
 
   * Improved the backward compatibility:
     - Restored the Enums.valueOfFunction() method (removed in Guava 18)
+    - Restored the Stopwatch methods and constructors (elapsedTime,
+      elapsedMillis and toString(int) removed in Guava 15 and 16)
 
  -- Emmanuel Bourg <ebourg at apache.org>  Fri, 03 Jul 2015 09:17:02 +0200
 
diff --git a/debian/patches/09-preserve-stopwatch-methods.patch b/debian/patches/09-preserve-stopwatch-methods.patch
new file mode 100644
index 0000000..e1c757e
--- /dev/null
+++ b/debian/patches/09-preserve-stopwatch-methods.patch
@@ -0,0 +1,97 @@
+Description: Preserves the Stopwatch methods and constructors removed in Guava 15 and 16.
+Author: Emmanuel Bourg <ebourg at apache.org>
+Forwarded: not-needed
+--- a/guava/src/com/google/common/base/Stopwatch.java
++++ b/guava/src/com/google/common/base/Stopwatch.java
+@@ -79,6 +79,8 @@
+   private long elapsedNanos;
+   private long startTick;
+ 
++
++
+   /**
+    * Creates (but does not start) a new stopwatch using {@link System#nanoTime}
+    * as its time source.
+@@ -126,7 +128,7 @@
+    * @deprecated Use {@link Stopwatch#createUnstarted()} instead.
+    */
+   @Deprecated
+-  Stopwatch() {
++  public Stopwatch() {
+     this(Ticker.systemTicker());
+   }
+ 
+@@ -137,7 +139,7 @@
+    * @deprecated Use {@link Stopwatch#createUnstarted(Ticker)} instead.
+    */
+   @Deprecated
+-  Stopwatch(Ticker ticker) {
++  public Stopwatch(Ticker ticker) {
+     this.ticker = checkNotNull(ticker, "ticker");
+   }
+ 
+@@ -209,6 +211,35 @@
+   }
+ 
+   /**
++   * Returns the current elapsed time shown on this stopwatch, expressed
++   * in the desired time unit, with any fraction rounded down.
++   *
++   * <p>Note that the overhead of measurement can be more than a microsecond, so
++   * it is generally not useful to specify {@link TimeUnit#NANOSECONDS}
++   * precision here.
++   *
++   * @deprecated Use {@link Stopwatch#elapsed(TimeUnit)} instead. This method is
++   *     scheduled to be removed in Guava release 16.0.
++   */
++  @Deprecated
++  public long elapsedTime(TimeUnit desiredUnit) {
++    return elapsed(desiredUnit);
++  }
++
++  /**
++   * Returns the current elapsed time shown on this stopwatch, expressed
++   * in milliseconds, with any fraction rounded down. This is identical to
++   * {@code elapsed(TimeUnit.MILLISECONDS)}.
++   *
++   * @deprecated Use {@code stopwatch.elapsed(MILLISECONDS)} instead. This
++   *     method is scheduled to be removed in Guava release 16.0.
++   */
++  @Deprecated
++  public long elapsedMillis() {
++    return elapsed(MILLISECONDS);
++  }
++
++  /**
+    * Returns a string representation of the current elapsed time.
+    */
+   @GwtIncompatible("String.format()")
+@@ -222,6 +253,28 @@
+     return String.format("%.4g %s", value, abbreviate(unit));
+   }
+ 
++  /**
++   * Returns a string representation of the current elapsed time, choosing an
++   * appropriate unit and using the specified number of significant figures.
++   * For example, at the instant when {@code elapsed(NANOSECONDS)} would
++   * return {1234567}, {@code toString(4)} returns {@code "1.235 ms"}.
++   *
++   * @deprecated Use {@link #toString()} instead. This method is scheduled
++   *     to be removed in Guava release 15.0.
++   */
++  @Deprecated
++  @GwtIncompatible("String.format()")
++  public String toString(int significantDigits) {
++    long nanos = elapsedNanos();
++
++    TimeUnit unit = chooseUnit(nanos);
++    double value = (double) nanos / NANOSECONDS.convert(1, unit);
++
++    // Too bad this functionality is not exposed as a regular method call
++    return String.format("%." + significantDigits + "g %s",
++        value, abbreviate(unit));
++  }
++
+   private static TimeUnit chooseUnit(long nanos) {
+     if (DAYS.convert(nanos, NANOSECONDS) > 0) {
+       return DAYS;
diff --git a/debian/patches/series b/debian/patches/series
index faf4a05..0a74d86 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -6,3 +6,4 @@
 06-preserve-pre-guava18-methods.patch
 07-java8-compatibility.patch
 08-preserve-enums-methods.patch
+09-preserve-stopwatch-methods.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/guava-libraries.git



More information about the pkg-java-commits mailing list