CacheLoader.java
3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package com.google.common.cache;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.base.Supplier;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListenableFutureTask;
import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
@GwtCompatible(emulated=true)
public abstract class CacheLoader<K, V>
{
@Beta
@GwtIncompatible("Executor + Futures")
public static <K, V> CacheLoader<K, V> asyncReloading(CacheLoader<K, V> paramCacheLoader, final Executor paramExecutor)
{
Preconditions.checkNotNull(paramCacheLoader);
Preconditions.checkNotNull(paramExecutor);
new CacheLoader()
{
public final V load(K paramAnonymousK)
throws Exception
{
return (V)this.a.load(paramAnonymousK);
}
public final Map<K, V> loadAll(Iterable<? extends K> paramAnonymousIterable)
throws Exception
{
return this.a.loadAll(paramAnonymousIterable);
}
public final ListenableFuture<V> reload(final K paramAnonymousK, final V paramAnonymousV)
throws Exception
{
paramAnonymousK = ListenableFutureTask.create(new Callable()
{
public final V call()
throws Exception
{
return (V)CacheLoader.1.this.a.reload(paramAnonymousK, paramAnonymousV).get();
}
});
paramExecutor.execute(paramAnonymousK);
return paramAnonymousK;
}
};
}
@Beta
public static <K, V> CacheLoader<K, V> from(Function<K, V> paramFunction)
{
return new a(paramFunction);
}
@Beta
public static <V> CacheLoader<Object, V> from(Supplier<V> paramSupplier)
{
return new b(paramSupplier);
}
public abstract V load(K paramK)
throws Exception;
public Map<K, V> loadAll(Iterable<? extends K> paramIterable)
throws Exception
{
throw new c();
}
@GwtIncompatible("Futures")
public ListenableFuture<V> reload(K paramK, V paramV)
throws Exception
{
Preconditions.checkNotNull(paramK);
Preconditions.checkNotNull(paramV);
return Futures.immediateFuture(load(paramK));
}
public static final class InvalidCacheLoadException
extends RuntimeException
{
public InvalidCacheLoadException(String paramString)
{
super();
}
}
static final class a<K, V>
extends CacheLoader<K, V>
implements Serializable
{
private static final long serialVersionUID = 0L;
private final Function<K, V> a;
public a(Function<K, V> paramFunction)
{
this.a = ((Function)Preconditions.checkNotNull(paramFunction));
}
public final V load(K paramK)
{
return (V)this.a.apply(Preconditions.checkNotNull(paramK));
}
}
static final class b<V>
extends CacheLoader<Object, V>
implements Serializable
{
private static final long serialVersionUID = 0L;
private final Supplier<V> a;
public b(Supplier<V> paramSupplier)
{
this.a = ((Supplier)Preconditions.checkNotNull(paramSupplier));
}
public final V load(Object paramObject)
{
Preconditions.checkNotNull(paramObject);
return (V)this.a.get();
}
}
public static final class c
extends UnsupportedOperationException
{}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/google/common/cache/CacheLoader.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/