Skip to content

Commit 73f8b0b

Browse files
klueverGoogle Java Core Libraries
authored andcommitted
Deprecate the (long, TimeUnit)-based APIs in CacheBuilder; please use the Duration-based APIs instead.
RELNOTES=deprecate legacy CacheBuilder APIs PiperOrigin-RevId: 816309096
1 parent 909c593 commit 73f8b0b

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎android/guava/src/com/google/common/cache/CacheBuilder.java‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,8 +750,9 @@ public CacheBuilder<K, V> expireAfterWrite(Duration duration) {
750750
* @return this {@code CacheBuilder} instance (for chaining)
751751
* @throws IllegalArgumentException if {@code duration} is negative
752752
* @throws IllegalStateException if {@link #expireAfterWrite} was already set
753+
* @deprecated Use {@link #expireAfterWrite(Duration)} instead.
753754
*/
754-
@SuppressWarnings("GoodTime") // should accept a Duration
755+
@Deprecated // GoodTime
755756
@CanIgnoreReturnValue
756757
public CacheBuilder<K, V> expireAfterWrite(long duration, TimeUnit unit) {
757758
checkState(
@@ -829,8 +830,9 @@ public CacheBuilder<K, V> expireAfterAccess(Duration duration) {
829830
* @return this {@code CacheBuilder} instance (for chaining)
830831
* @throws IllegalArgumentException if {@code duration} is negative
831832
* @throws IllegalStateException if {@link #expireAfterAccess} was already set
833+
* @deprecated Use {@link #expireAfterAccess(Duration)} instead.
832834
*/
833-
@SuppressWarnings("GoodTime") // should accept a Duration
835+
@Deprecated // GoodTime
834836
@CanIgnoreReturnValue
835837
public CacheBuilder<K, V> expireAfterAccess(long duration, TimeUnit unit) {
836838
checkState(
@@ -915,9 +917,10 @@ public CacheBuilder<K, V> refreshAfterWrite(Duration duration) {
915917
* @throws IllegalArgumentException if {@code duration} is negative
916918
* @throws IllegalStateException if {@link #refreshAfterWrite} was already set
917919
* @since 11.0
920+
* @deprecated Use {@link #refreshAfterWrite(Duration)} instead.
918921
*/
919922
@GwtIncompatible // To be supported (synchronously).
920-
@SuppressWarnings("GoodTime") // should accept a Duration
923+
@Deprecated // GoodTime
921924
@CanIgnoreReturnValue
922925
public CacheBuilder<K, V> refreshAfterWrite(long duration, TimeUnit unit) {
923926
checkNotNull(unit);

‎guava/src/com/google/common/cache/CacheBuilder.java‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -749,8 +749,9 @@ public CacheBuilder<K, V> expireAfterWrite(Duration duration) {
749749
* @return this {@code CacheBuilder} instance (for chaining)
750750
* @throws IllegalArgumentException if {@code duration} is negative
751751
* @throws IllegalStateException if {@link #expireAfterWrite} was already set
752+
* @deprecated Use {@link #expireAfterWrite(Duration)} instead.
752753
*/
753-
@SuppressWarnings("GoodTime") // should accept a Duration
754+
@Deprecated // GoodTime
754755
@CanIgnoreReturnValue
755756
public CacheBuilder<K, V> expireAfterWrite(long duration, TimeUnit unit) {
756757
checkState(
@@ -827,8 +828,9 @@ public CacheBuilder<K, V> expireAfterAccess(Duration duration) {
827828
* @return this {@code CacheBuilder} instance (for chaining)
828829
* @throws IllegalArgumentException if {@code duration} is negative
829830
* @throws IllegalStateException if {@link #expireAfterAccess} was already set
831+
* @deprecated Use {@link #expireAfterAccess(Duration)} instead.
830832
*/
831-
@SuppressWarnings("GoodTime") // should accept a Duration
833+
@Deprecated // GoodTime
832834
@CanIgnoreReturnValue
833835
public CacheBuilder<K, V> expireAfterAccess(long duration, TimeUnit unit) {
834836
checkState(
@@ -912,9 +914,10 @@ public CacheBuilder<K, V> refreshAfterWrite(Duration duration) {
912914
* @throws IllegalArgumentException if {@code duration} is negative
913915
* @throws IllegalStateException if {@link #refreshAfterWrite} was already set
914916
* @since 11.0
917+
* @deprecated Use {@link #refreshAfterWrite(Duration)} instead.
915918
*/
916919
@GwtIncompatible // To be supported (synchronously).
917-
@SuppressWarnings("GoodTime") // should accept a Duration
920+
@Deprecated // GoodTime
918921
@CanIgnoreReturnValue
919922
public CacheBuilder<K, V> refreshAfterWrite(long duration, TimeUnit unit) {
920923
checkNotNull(unit);

0 commit comments

Comments
 (0)
⌂ 换网址