Skip to content

Commit

Permalink
Add duration info to checkArugment() call in Suppliers.memoizeWithExp…
Browse files Browse the repository at this point in the history
…iration()

RELNOTES=Add duration info to checkArugment() call in Suppliers.memoizeWithExpiration()

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=198051129
  • Loading branch information
kluever authored and cpovirk committed May 29, 2018
1 parent 0f49eb5 commit 4adedb7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
21 changes: 11 additions & 10 deletions android/guava/src/com/google/common/base/Suppliers.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

package com.google.common.base;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
import java.io.Serializable;
Expand All @@ -40,8 +43,6 @@ private Suppliers() {}
* call {@code supplier} or invoke {@code function} until it is called.
*/
public static <F, T> Supplier<T> compose(Function<? super F, T> function, Supplier<F> supplier) {
Preconditions.checkNotNull(function);
Preconditions.checkNotNull(supplier);
return new SupplierComposition<>(function, supplier);
}

Expand All @@ -50,8 +51,8 @@ private static class SupplierComposition<F, T> implements Supplier<T>, Serializa
final Supplier<F> supplier;

SupplierComposition(Function<? super F, T> function, Supplier<F> supplier) {
this.function = function;
this.supplier = supplier;
this.function = checkNotNull(function);
this.supplier = checkNotNull(supplier);
}

@Override
Expand Down Expand Up @@ -116,7 +117,7 @@ static class MemoizingSupplier<T> implements Supplier<T>, Serializable {
@NullableDecl transient T value;

MemoizingSupplier(Supplier<T> delegate) {
this.delegate = Preconditions.checkNotNull(delegate);
this.delegate = checkNotNull(delegate);
}

@Override
Expand Down Expand Up @@ -154,7 +155,7 @@ static class NonSerializableMemoizingSupplier<T> implements Supplier<T> {
@NullableDecl T value;

NonSerializableMemoizingSupplier(Supplier<T> delegate) {
this.delegate = Preconditions.checkNotNull(delegate);
this.delegate = checkNotNull(delegate);
}

@Override
Expand Down Expand Up @@ -219,9 +220,9 @@ static class ExpiringMemoizingSupplier<T> implements Supplier<T>, Serializable {
transient volatile long expirationNanos;

ExpiringMemoizingSupplier(Supplier<T> delegate, long duration, TimeUnit unit) {
this.delegate = Preconditions.checkNotNull(delegate);
this.delegate = checkNotNull(delegate);
this.durationNanos = unit.toNanos(duration);
Preconditions.checkArgument(duration > 0);
checkArgument(duration > 0, "duration (%s %s) must be > 0", duration, unit);
}

@Override
Expand Down Expand Up @@ -304,14 +305,14 @@ public String toString() {
* it, making it thread-safe.
*/
public static <T> Supplier<T> synchronizedSupplier(Supplier<T> delegate) {
return new ThreadSafeSupplier<T>(Preconditions.checkNotNull(delegate));
return new ThreadSafeSupplier<T>(delegate);
}

private static class ThreadSafeSupplier<T> implements Supplier<T>, Serializable {
final Supplier<T> delegate;

ThreadSafeSupplier(Supplier<T> delegate) {
this.delegate = delegate;
this.delegate = checkNotNull(delegate);
}

@Override
Expand Down
21 changes: 11 additions & 10 deletions guava/src/com/google/common/base/Suppliers.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

package com.google.common.base;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
import java.io.Serializable;
Expand All @@ -40,8 +43,6 @@ private Suppliers() {}
* call {@code supplier} or invoke {@code function} until it is called.
*/
public static <F, T> Supplier<T> compose(Function<? super F, T> function, Supplier<F> supplier) {
Preconditions.checkNotNull(function);
Preconditions.checkNotNull(supplier);
return new SupplierComposition<>(function, supplier);
}

Expand All @@ -50,8 +51,8 @@ private static class SupplierComposition<F, T> implements Supplier<T>, Serializa
final Supplier<F> supplier;

SupplierComposition(Function<? super F, T> function, Supplier<F> supplier) {
this.function = function;
this.supplier = supplier;
this.function = checkNotNull(function);
this.supplier = checkNotNull(supplier);
}

@Override
Expand Down Expand Up @@ -116,7 +117,7 @@ static class MemoizingSupplier<T> implements Supplier<T>, Serializable {
transient @Nullable T value;

MemoizingSupplier(Supplier<T> delegate) {
this.delegate = Preconditions.checkNotNull(delegate);
this.delegate = checkNotNull(delegate);
}

@Override
Expand Down Expand Up @@ -154,7 +155,7 @@ static class NonSerializableMemoizingSupplier<T> implements Supplier<T> {
@Nullable T value;

NonSerializableMemoizingSupplier(Supplier<T> delegate) {
this.delegate = Preconditions.checkNotNull(delegate);
this.delegate = checkNotNull(delegate);
}

@Override
Expand Down Expand Up @@ -219,9 +220,9 @@ static class ExpiringMemoizingSupplier<T> implements Supplier<T>, Serializable {
transient volatile long expirationNanos;

ExpiringMemoizingSupplier(Supplier<T> delegate, long duration, TimeUnit unit) {
this.delegate = Preconditions.checkNotNull(delegate);
this.delegate = checkNotNull(delegate);
this.durationNanos = unit.toNanos(duration);
Preconditions.checkArgument(duration > 0);
checkArgument(duration > 0, "duration (%s %s) must be > 0", duration, unit);
}

@Override
Expand Down Expand Up @@ -304,14 +305,14 @@ public String toString() {
* it, making it thread-safe.
*/
public static <T> Supplier<T> synchronizedSupplier(Supplier<T> delegate) {
return new ThreadSafeSupplier<T>(Preconditions.checkNotNull(delegate));
return new ThreadSafeSupplier<T>(delegate);
}

private static class ThreadSafeSupplier<T> implements Supplier<T>, Serializable {
final Supplier<T> delegate;

ThreadSafeSupplier(Supplier<T> delegate) {
this.delegate = delegate;
this.delegate = checkNotNull(delegate);
}

@Override
Expand Down

0 comments on commit 4adedb7

Please sign in to comment.