decompile with cfr

This commit is contained in:
Merith-TK 2022-08-09 23:01:55 -07:00
commit 7d26cb34a1
1987 changed files with 238867 additions and 0 deletions

View file

@ -0,0 +1,18 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.annotations;
import com.google.common.annotations.GwtCompatible;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(value=RetentionPolicy.CLASS)
@Target(value={ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
@Documented
@GwtCompatible
public @interface Beta {
}

View file

@ -0,0 +1,20 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(value=RetentionPolicy.CLASS)
@Target(value={ElementType.TYPE, ElementType.METHOD})
@Documented
@GwtCompatible
public @interface GwtCompatible {
public boolean serializable() default false;
public boolean emulated() default false;
}

View file

@ -0,0 +1,19 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.annotations;
import com.google.common.annotations.GwtCompatible;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(value=RetentionPolicy.CLASS)
@Target(value={ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD})
@Documented
@GwtCompatible
public @interface GwtIncompatible {
public String value();
}

View file

@ -0,0 +1,10 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.annotations;
import com.google.common.annotations.GwtCompatible;
@GwtCompatible
public @interface VisibleForTesting {
}

View file

@ -0,0 +1,88 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Supplier;
import java.util.Collections;
import java.util.Set;
import javax.annotation.Nullable;
@GwtCompatible
final class Absent<T>
extends Optional<T> {
static final Absent<Object> INSTANCE = new Absent();
private static final long serialVersionUID = 0L;
static <T> Optional<T> withType() {
return INSTANCE;
}
private Absent() {
}
@Override
public boolean isPresent() {
return false;
}
@Override
public T get() {
throw new IllegalStateException("Optional.get() cannot be called on an absent value");
}
@Override
public T or(T defaultValue) {
return Preconditions.checkNotNull(defaultValue, "use Optional.orNull() instead of Optional.or(null)");
}
@Override
public Optional<T> or(Optional<? extends T> secondChoice) {
return Preconditions.checkNotNull(secondChoice);
}
@Override
public T or(Supplier<? extends T> supplier) {
return Preconditions.checkNotNull(supplier.get(), "use Optional.orNull() instead of a Supplier that returns null");
}
@Override
@Nullable
public T orNull() {
return null;
}
@Override
public Set<T> asSet() {
return Collections.emptySet();
}
@Override
public <V> Optional<V> transform(Function<? super T, V> function) {
Preconditions.checkNotNull(function);
return Optional.absent();
}
@Override
public boolean equals(@Nullable Object object) {
return object == this;
}
@Override
public int hashCode() {
return 1502476572;
}
@Override
public String toString() {
return "Optional.absent()";
}
private Object readResolve() {
return INSTANCE;
}
}

View file

@ -0,0 +1,74 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Preconditions;
import java.util.Iterator;
import java.util.NoSuchElementException;
@GwtCompatible
abstract class AbstractIterator<T>
implements Iterator<T> {
private State state = State.NOT_READY;
private T next;
protected AbstractIterator() {
}
protected abstract T computeNext();
protected final T endOfData() {
this.state = State.DONE;
return null;
}
@Override
public final boolean hasNext() {
Preconditions.checkState(this.state != State.FAILED);
switch (this.state) {
case DONE: {
return false;
}
case READY: {
return true;
}
}
return this.tryToComputeNext();
}
private boolean tryToComputeNext() {
this.state = State.FAILED;
this.next = this.computeNext();
if (this.state != State.DONE) {
this.state = State.READY;
return true;
}
return false;
}
@Override
public final T next() {
if (!this.hasNext()) {
throw new NoSuchElementException();
}
this.state = State.NOT_READY;
T result = this.next;
this.next = null;
return result;
}
@Override
public final void remove() {
throw new UnsupportedOperationException();
}
private static enum State {
READY,
NOT_READY,
DONE,
FAILED;
}
}

View file

@ -0,0 +1,169 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Preconditions;
import javax.annotation.CheckReturnValue;
@GwtCompatible
public final class Ascii {
public static final byte NUL = 0;
public static final byte SOH = 1;
public static final byte STX = 2;
public static final byte ETX = 3;
public static final byte EOT = 4;
public static final byte ENQ = 5;
public static final byte ACK = 6;
public static final byte BEL = 7;
public static final byte BS = 8;
public static final byte HT = 9;
public static final byte LF = 10;
public static final byte NL = 10;
public static final byte VT = 11;
public static final byte FF = 12;
public static final byte CR = 13;
public static final byte SO = 14;
public static final byte SI = 15;
public static final byte DLE = 16;
public static final byte DC1 = 17;
public static final byte XON = 17;
public static final byte DC2 = 18;
public static final byte DC3 = 19;
public static final byte XOFF = 19;
public static final byte DC4 = 20;
public static final byte NAK = 21;
public static final byte SYN = 22;
public static final byte ETB = 23;
public static final byte CAN = 24;
public static final byte EM = 25;
public static final byte SUB = 26;
public static final byte ESC = 27;
public static final byte FS = 28;
public static final byte GS = 29;
public static final byte RS = 30;
public static final byte US = 31;
public static final byte SP = 32;
public static final byte SPACE = 32;
public static final byte DEL = 127;
public static final char MIN = '\u0000';
public static final char MAX = '\u007f';
private Ascii() {
}
public static String toLowerCase(String string) {
int length = string.length();
for (int i = 0; i < length; ++i) {
if (!Ascii.isUpperCase(string.charAt(i))) continue;
char[] chars = string.toCharArray();
while (i < length) {
char c = chars[i];
if (Ascii.isUpperCase(c)) {
chars[i] = (char)(c ^ 0x20);
}
++i;
}
return String.valueOf(chars);
}
return string;
}
public static String toLowerCase(CharSequence chars) {
if (chars instanceof String) {
return Ascii.toLowerCase((String)chars);
}
int length = chars.length();
StringBuilder builder = new StringBuilder(length);
for (int i = 0; i < length; ++i) {
builder.append(Ascii.toLowerCase(chars.charAt(i)));
}
return builder.toString();
}
public static char toLowerCase(char c) {
return Ascii.isUpperCase(c) ? (char)(c ^ 0x20) : c;
}
public static String toUpperCase(String string) {
int length = string.length();
for (int i = 0; i < length; ++i) {
if (!Ascii.isLowerCase(string.charAt(i))) continue;
char[] chars = string.toCharArray();
while (i < length) {
char c = chars[i];
if (Ascii.isLowerCase(c)) {
chars[i] = (char)(c & 0x5F);
}
++i;
}
return String.valueOf(chars);
}
return string;
}
public static String toUpperCase(CharSequence chars) {
if (chars instanceof String) {
return Ascii.toUpperCase((String)chars);
}
int length = chars.length();
StringBuilder builder = new StringBuilder(length);
for (int i = 0; i < length; ++i) {
builder.append(Ascii.toUpperCase(chars.charAt(i)));
}
return builder.toString();
}
public static char toUpperCase(char c) {
return Ascii.isLowerCase(c) ? (char)(c & 0x5F) : c;
}
public static boolean isLowerCase(char c) {
return c >= 'a' && c <= 'z';
}
public static boolean isUpperCase(char c) {
return c >= 'A' && c <= 'Z';
}
@CheckReturnValue
@Beta
public static String truncate(CharSequence seq, int maxLength, String truncationIndicator) {
Preconditions.checkNotNull(seq);
int truncationLength = maxLength - truncationIndicator.length();
Preconditions.checkArgument(truncationLength >= 0, "maxLength (%s) must be >= length of the truncation indicator (%s)", maxLength, truncationIndicator.length());
if (seq.length() <= maxLength) {
String string = seq.toString();
if (string.length() <= maxLength) {
return string;
}
seq = string;
}
return new StringBuilder(maxLength).append(seq, 0, truncationLength).append(truncationIndicator).toString();
}
@Beta
public static boolean equalsIgnoreCase(CharSequence s1, CharSequence s2) {
int length = s1.length();
if (s1 == s2) {
return true;
}
if (length != s2.length()) {
return false;
}
for (int i = 0; i < length; ++i) {
int alphaIndex;
char c2;
char c1 = s1.charAt(i);
if (c1 == (c2 = s2.charAt(i)) || (alphaIndex = Ascii.getAlphaIndex(c1)) < 26 && alphaIndex == Ascii.getAlphaIndex(c2)) continue;
return false;
}
return true;
}
private static int getAlphaIndex(char c) {
return (char)((c | 0x20) - 97);
}
}

View file

@ -0,0 +1,179 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Ascii;
import com.google.common.base.CharMatcher;
import com.google.common.base.Converter;
import com.google.common.base.Preconditions;
import java.io.Serializable;
import javax.annotation.Nullable;
@GwtCompatible
public enum CaseFormat {
LOWER_HYPHEN(CharMatcher.is('-'), "-"){
@Override
String normalizeWord(String word) {
return Ascii.toLowerCase(word);
}
@Override
String convert(CaseFormat format, String s) {
if (format == LOWER_UNDERSCORE) {
return s.replace('-', '_');
}
if (format == UPPER_UNDERSCORE) {
return Ascii.toUpperCase(s.replace('-', '_'));
}
return super.convert(format, s);
}
}
,
LOWER_UNDERSCORE(CharMatcher.is('_'), "_"){
@Override
String normalizeWord(String word) {
return Ascii.toLowerCase(word);
}
@Override
String convert(CaseFormat format, String s) {
if (format == LOWER_HYPHEN) {
return s.replace('_', '-');
}
if (format == UPPER_UNDERSCORE) {
return Ascii.toUpperCase(s);
}
return super.convert(format, s);
}
}
,
LOWER_CAMEL(CharMatcher.inRange('A', 'Z'), ""){
@Override
String normalizeWord(String word) {
return CaseFormat.firstCharOnlyToUpper(word);
}
}
,
UPPER_CAMEL(CharMatcher.inRange('A', 'Z'), ""){
@Override
String normalizeWord(String word) {
return CaseFormat.firstCharOnlyToUpper(word);
}
}
,
UPPER_UNDERSCORE(CharMatcher.is('_'), "_"){
@Override
String normalizeWord(String word) {
return Ascii.toUpperCase(word);
}
@Override
String convert(CaseFormat format, String s) {
if (format == LOWER_HYPHEN) {
return Ascii.toLowerCase(s.replace('_', '-'));
}
if (format == LOWER_UNDERSCORE) {
return Ascii.toLowerCase(s);
}
return super.convert(format, s);
}
};
private final CharMatcher wordBoundary;
private final String wordSeparator;
private CaseFormat(CharMatcher wordBoundary, String wordSeparator) {
this.wordBoundary = wordBoundary;
this.wordSeparator = wordSeparator;
}
public final String to(CaseFormat format, String str) {
Preconditions.checkNotNull(format);
Preconditions.checkNotNull(str);
return format == this ? str : this.convert(format, str);
}
String convert(CaseFormat format, String s) {
StringBuilder out = null;
int i = 0;
int j = -1;
while (true) {
++j;
if ((j = this.wordBoundary.indexIn(s, j)) == -1) break;
if (i == 0) {
out = new StringBuilder(s.length() + 4 * this.wordSeparator.length());
out.append(format.normalizeFirstWord(s.substring(i, j)));
} else {
out.append(format.normalizeWord(s.substring(i, j)));
}
out.append(format.wordSeparator);
i = j + this.wordSeparator.length();
}
return i == 0 ? format.normalizeFirstWord(s) : out.append(format.normalizeWord(s.substring(i))).toString();
}
@Beta
public Converter<String, String> converterTo(CaseFormat targetFormat) {
return new StringConverter(this, targetFormat);
}
abstract String normalizeWord(String var1);
private String normalizeFirstWord(String word) {
return this == LOWER_CAMEL ? Ascii.toLowerCase(word) : this.normalizeWord(word);
}
private static String firstCharOnlyToUpper(String word) {
return word.isEmpty() ? word : new StringBuilder(word.length()).append(Ascii.toUpperCase(word.charAt(0))).append(Ascii.toLowerCase(word.substring(1))).toString();
}
private static final class StringConverter
extends Converter<String, String>
implements Serializable {
private final CaseFormat sourceFormat;
private final CaseFormat targetFormat;
private static final long serialVersionUID = 0L;
StringConverter(CaseFormat sourceFormat, CaseFormat targetFormat) {
this.sourceFormat = Preconditions.checkNotNull(sourceFormat);
this.targetFormat = Preconditions.checkNotNull(targetFormat);
}
@Override
protected String doForward(String s) {
return s == null ? null : this.sourceFormat.to(this.targetFormat, s);
}
@Override
protected String doBackward(String s) {
return s == null ? null : this.targetFormat.to(this.sourceFormat, s);
}
@Override
public boolean equals(@Nullable Object object) {
if (object instanceof StringConverter) {
StringConverter that = (StringConverter)object;
return this.sourceFormat.equals((Object)that.sourceFormat) && this.targetFormat.equals((Object)that.targetFormat);
}
return false;
}
public int hashCode() {
return this.sourceFormat.hashCode() ^ this.targetFormat.hashCode();
}
public String toString() {
String string = String.valueOf(String.valueOf((Object)this.sourceFormat));
String string2 = String.valueOf(String.valueOf((Object)this.targetFormat));
return new StringBuilder(14 + string.length() + string2.length()).append(string).append(".converterTo(").append(string2).append(")").toString();
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,26 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import java.nio.charset.Charset;
@GwtCompatible(emulated=true)
public final class Charsets {
@GwtIncompatible(value="Non-UTF-8 Charset")
public static final Charset US_ASCII = Charset.forName("US-ASCII");
@GwtIncompatible(value="Non-UTF-8 Charset")
public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
public static final Charset UTF_8 = Charset.forName("UTF-8");
@GwtIncompatible(value="Non-UTF-8 Charset")
public static final Charset UTF_16BE = Charset.forName("UTF-16BE");
@GwtIncompatible(value="Non-UTF-8 Charset")
public static final Charset UTF_16LE = Charset.forName("UTF-16LE");
@GwtIncompatible(value="Non-UTF-8 Charset")
public static final Charset UTF_16 = Charset.forName("UTF-16");
private Charsets() {
}
}

View file

@ -0,0 +1,305 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import java.io.Serializable;
import java.util.Iterator;
import javax.annotation.Nullable;
@Beta
@GwtCompatible
public abstract class Converter<A, B>
implements Function<A, B> {
private final boolean handleNullAutomatically;
private transient Converter<B, A> reverse;
protected Converter() {
this(true);
}
Converter(boolean handleNullAutomatically) {
this.handleNullAutomatically = handleNullAutomatically;
}
protected abstract B doForward(A var1);
protected abstract A doBackward(B var1);
@Nullable
public final B convert(@Nullable A a) {
return this.correctedDoForward(a);
}
@Nullable
B correctedDoForward(@Nullable A a) {
if (this.handleNullAutomatically) {
return a == null ? null : (B)Preconditions.checkNotNull(this.doForward(a));
}
return this.doForward(a);
}
@Nullable
A correctedDoBackward(@Nullable B b) {
if (this.handleNullAutomatically) {
return b == null ? null : (A)Preconditions.checkNotNull(this.doBackward(b));
}
return this.doBackward(b);
}
public Iterable<B> convertAll(final Iterable<? extends A> fromIterable) {
Preconditions.checkNotNull(fromIterable, "fromIterable");
return new Iterable<B>(){
@Override
public Iterator<B> iterator() {
return new Iterator<B>(){
private final Iterator<? extends A> fromIterator;
{
this.fromIterator = fromIterable.iterator();
}
@Override
public boolean hasNext() {
return this.fromIterator.hasNext();
}
@Override
public B next() {
return Converter.this.convert(this.fromIterator.next());
}
@Override
public void remove() {
this.fromIterator.remove();
}
};
}
};
}
public Converter<B, A> reverse() {
Converter<A, B> result = this.reverse;
return result == null ? (this.reverse = new ReverseConverter(this)) : result;
}
public final <C> Converter<A, C> andThen(Converter<B, C> secondConverter) {
return this.doAndThen(secondConverter);
}
<C> Converter<A, C> doAndThen(Converter<B, C> secondConverter) {
return new ConverterComposition(this, Preconditions.checkNotNull(secondConverter));
}
@Override
@Deprecated
@Nullable
public final B apply(@Nullable A a) {
return this.convert(a);
}
@Override
public boolean equals(@Nullable Object object) {
return super.equals(object);
}
public static <A, B> Converter<A, B> from(Function<? super A, ? extends B> forwardFunction, Function<? super B, ? extends A> backwardFunction) {
return new FunctionBasedConverter(forwardFunction, backwardFunction);
}
public static <T> Converter<T, T> identity() {
return IdentityConverter.INSTANCE;
}
private static final class IdentityConverter<T>
extends Converter<T, T>
implements Serializable {
static final IdentityConverter INSTANCE = new IdentityConverter();
private static final long serialVersionUID = 0L;
private IdentityConverter() {
}
@Override
protected T doForward(T t) {
return t;
}
@Override
protected T doBackward(T t) {
return t;
}
public IdentityConverter<T> reverse() {
return this;
}
@Override
<S> Converter<T, S> doAndThen(Converter<T, S> otherConverter) {
return Preconditions.checkNotNull(otherConverter, "otherConverter");
}
public String toString() {
return "Converter.identity()";
}
private Object readResolve() {
return INSTANCE;
}
}
private static final class FunctionBasedConverter<A, B>
extends Converter<A, B>
implements Serializable {
private final Function<? super A, ? extends B> forwardFunction;
private final Function<? super B, ? extends A> backwardFunction;
private FunctionBasedConverter(Function<? super A, ? extends B> forwardFunction, Function<? super B, ? extends A> backwardFunction) {
this.forwardFunction = Preconditions.checkNotNull(forwardFunction);
this.backwardFunction = Preconditions.checkNotNull(backwardFunction);
}
@Override
protected B doForward(A a) {
return this.forwardFunction.apply(a);
}
@Override
protected A doBackward(B b) {
return this.backwardFunction.apply(b);
}
@Override
public boolean equals(@Nullable Object object) {
if (object instanceof FunctionBasedConverter) {
FunctionBasedConverter that = (FunctionBasedConverter)object;
return this.forwardFunction.equals(that.forwardFunction) && this.backwardFunction.equals(that.backwardFunction);
}
return false;
}
public int hashCode() {
return this.forwardFunction.hashCode() * 31 + this.backwardFunction.hashCode();
}
public String toString() {
String string = String.valueOf(String.valueOf(this.forwardFunction));
String string2 = String.valueOf(String.valueOf(this.backwardFunction));
return new StringBuilder(18 + string.length() + string2.length()).append("Converter.from(").append(string).append(", ").append(string2).append(")").toString();
}
}
private static final class ConverterComposition<A, B, C>
extends Converter<A, C>
implements Serializable {
final Converter<A, B> first;
final Converter<B, C> second;
private static final long serialVersionUID = 0L;
ConverterComposition(Converter<A, B> first, Converter<B, C> second) {
this.first = first;
this.second = second;
}
@Override
protected C doForward(A a) {
throw new AssertionError();
}
@Override
protected A doBackward(C c) {
throw new AssertionError();
}
@Override
@Nullable
C correctedDoForward(@Nullable A a) {
return this.second.correctedDoForward(this.first.correctedDoForward(a));
}
@Override
@Nullable
A correctedDoBackward(@Nullable C c) {
return this.first.correctedDoBackward(this.second.correctedDoBackward(c));
}
@Override
public boolean equals(@Nullable Object object) {
if (object instanceof ConverterComposition) {
ConverterComposition that = (ConverterComposition)object;
return this.first.equals(that.first) && this.second.equals(that.second);
}
return false;
}
public int hashCode() {
return 31 * this.first.hashCode() + this.second.hashCode();
}
public String toString() {
String string = String.valueOf(String.valueOf(this.first));
String string2 = String.valueOf(String.valueOf(this.second));
return new StringBuilder(10 + string.length() + string2.length()).append(string).append(".andThen(").append(string2).append(")").toString();
}
}
private static final class ReverseConverter<A, B>
extends Converter<B, A>
implements Serializable {
final Converter<A, B> original;
private static final long serialVersionUID = 0L;
ReverseConverter(Converter<A, B> original) {
this.original = original;
}
@Override
protected A doForward(B b) {
throw new AssertionError();
}
@Override
protected B doBackward(A a) {
throw new AssertionError();
}
@Override
@Nullable
A correctedDoForward(@Nullable B b) {
return this.original.correctedDoBackward(b);
}
@Override
@Nullable
B correctedDoBackward(@Nullable A a) {
return this.original.correctedDoForward(a);
}
@Override
public Converter<A, B> reverse() {
return this.original;
}
@Override
public boolean equals(@Nullable Object object) {
if (object instanceof ReverseConverter) {
ReverseConverter that = (ReverseConverter)object;
return this.original.equals(that.original);
}
return false;
}
public int hashCode() {
return ~this.original.hashCode();
}
public String toString() {
String string = String.valueOf(String.valueOf(this.original));
return new StringBuilder(10 + string.length()).append(string).append(".reverse()").toString();
}
}
}

View file

@ -0,0 +1,40 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.base.Preconditions;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
public final class Defaults {
private static final Map<Class<?>, Object> DEFAULTS;
private Defaults() {
}
private static <T> void put(Map<Class<?>, Object> map, Class<T> type, T value) {
map.put(type, value);
}
@Nullable
public static <T> T defaultValue(Class<T> type) {
Object t = DEFAULTS.get(Preconditions.checkNotNull(type));
return (T)t;
}
static {
HashMap map = new HashMap();
Defaults.put(map, Boolean.TYPE, false);
Defaults.put(map, Character.TYPE, Character.valueOf('\u0000'));
Defaults.put(map, Byte.TYPE, (byte)0);
Defaults.put(map, Short.TYPE, (short)0);
Defaults.put(map, Integer.TYPE, 0);
Defaults.put(map, Long.TYPE, 0L);
Defaults.put(map, Float.TYPE, Float.valueOf(0.0f));
Defaults.put(map, Double.TYPE, 0.0);
DEFAULTS = Collections.unmodifiableMap(map);
}
}

View file

@ -0,0 +1,115 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Converter;
import com.google.common.base.Optional;
import com.google.common.base.Platform;
import com.google.common.base.Preconditions;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;
import javax.annotation.Nullable;
@GwtCompatible(emulated=true)
@Beta
public final class Enums {
@GwtIncompatible(value="java.lang.ref.WeakReference")
private static final Map<Class<? extends Enum<?>>, Map<String, WeakReference<? extends Enum<?>>>> enumConstantCache = new WeakHashMap();
private Enums() {
}
@GwtIncompatible(value="reflection")
public static Field getField(Enum<?> enumValue) {
Class<?> clazz = enumValue.getDeclaringClass();
try {
return clazz.getDeclaredField(enumValue.name());
}
catch (NoSuchFieldException impossible) {
throw new AssertionError((Object)impossible);
}
}
public static <T extends Enum<T>> Optional<T> getIfPresent(Class<T> enumClass, String value) {
Preconditions.checkNotNull(enumClass);
Preconditions.checkNotNull(value);
return Platform.getEnumIfPresent(enumClass, value);
}
@GwtIncompatible(value="java.lang.ref.WeakReference")
private static <T extends Enum<T>> Map<String, WeakReference<? extends Enum<?>>> populateCache(Class<T> enumClass) {
HashMap result = new HashMap();
for (Enum enumInstance : EnumSet.allOf(enumClass)) {
result.put(enumInstance.name(), new WeakReference<Enum>(enumInstance));
}
enumConstantCache.put(enumClass, result);
return result;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
@GwtIncompatible(value="java.lang.ref.WeakReference")
static <T extends Enum<T>> Map<String, WeakReference<? extends Enum<?>>> getEnumConstants(Class<T> enumClass) {
Map<Class<? extends Enum<?>>, Map<String, WeakReference<? extends Enum<?>>>> map = enumConstantCache;
synchronized (map) {
Map<String, WeakReference<Enum>> constants = enumConstantCache.get(enumClass);
if (constants == null) {
constants = Enums.populateCache(enumClass);
}
return constants;
}
}
public static <T extends Enum<T>> Converter<String, T> stringConverter(Class<T> enumClass) {
return new StringConverter<T>(enumClass);
}
private static final class StringConverter<T extends Enum<T>>
extends Converter<String, T>
implements Serializable {
private final Class<T> enumClass;
private static final long serialVersionUID = 0L;
StringConverter(Class<T> enumClass) {
this.enumClass = Preconditions.checkNotNull(enumClass);
}
@Override
protected T doForward(String value) {
return Enum.valueOf(this.enumClass, value);
}
@Override
protected String doBackward(T enumValue) {
return ((Enum)enumValue).name();
}
@Override
public boolean equals(@Nullable Object object) {
if (object instanceof StringConverter) {
StringConverter that = (StringConverter)object;
return this.enumClass.equals(that.enumClass);
}
return false;
}
public int hashCode() {
return this.enumClass.hashCode();
}
public String toString() {
String string = String.valueOf(String.valueOf(this.enumClass.getName()));
return new StringBuilder(29 + string.length()).append("Enums.stringConverter(").append(string).append(".class)").toString();
}
}
}

View file

@ -0,0 +1,199 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Function;
import com.google.common.base.FunctionalEquivalence;
import com.google.common.base.Objects;
import com.google.common.base.PairwiseEquivalence;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import java.io.Serializable;
import javax.annotation.Nullable;
@GwtCompatible
public abstract class Equivalence<T> {
protected Equivalence() {
}
public final boolean equivalent(@Nullable T a, @Nullable T b) {
if (a == b) {
return true;
}
if (a == null || b == null) {
return false;
}
return this.doEquivalent(a, b);
}
protected abstract boolean doEquivalent(T var1, T var2);
public final int hash(@Nullable T t) {
if (t == null) {
return 0;
}
return this.doHash(t);
}
protected abstract int doHash(T var1);
public final <F> Equivalence<F> onResultOf(Function<F, ? extends T> function) {
return new FunctionalEquivalence<F, T>(function, this);
}
public final <S extends T> Wrapper<S> wrap(@Nullable S reference) {
return new Wrapper(this, reference);
}
@GwtCompatible(serializable=true)
public final <S extends T> Equivalence<Iterable<S>> pairwise() {
return new PairwiseEquivalence(this);
}
@Beta
public final Predicate<T> equivalentTo(@Nullable T target) {
return new EquivalentToPredicate<T>(this, target);
}
public static Equivalence<Object> equals() {
return Equals.INSTANCE;
}
public static Equivalence<Object> identity() {
return Identity.INSTANCE;
}
static final class Identity
extends Equivalence<Object>
implements Serializable {
static final Identity INSTANCE = new Identity();
private static final long serialVersionUID = 1L;
Identity() {
}
@Override
protected boolean doEquivalent(Object a, Object b) {
return false;
}
@Override
protected int doHash(Object o) {
return System.identityHashCode(o);
}
private Object readResolve() {
return INSTANCE;
}
}
static final class Equals
extends Equivalence<Object>
implements Serializable {
static final Equals INSTANCE = new Equals();
private static final long serialVersionUID = 1L;
Equals() {
}
@Override
protected boolean doEquivalent(Object a, Object b) {
return a.equals(b);
}
@Override
protected int doHash(Object o) {
return o.hashCode();
}
private Object readResolve() {
return INSTANCE;
}
}
private static final class EquivalentToPredicate<T>
implements Predicate<T>,
Serializable {
private final Equivalence<T> equivalence;
@Nullable
private final T target;
private static final long serialVersionUID = 0L;
EquivalentToPredicate(Equivalence<T> equivalence, @Nullable T target) {
this.equivalence = Preconditions.checkNotNull(equivalence);
this.target = target;
}
@Override
public boolean apply(@Nullable T input) {
return this.equivalence.equivalent(input, this.target);
}
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof EquivalentToPredicate) {
EquivalentToPredicate that = (EquivalentToPredicate)obj;
return this.equivalence.equals(that.equivalence) && Objects.equal(this.target, that.target);
}
return false;
}
public int hashCode() {
return Objects.hashCode(this.equivalence, this.target);
}
public String toString() {
String string = String.valueOf(String.valueOf(this.equivalence));
String string2 = String.valueOf(String.valueOf(this.target));
return new StringBuilder(15 + string.length() + string2.length()).append(string).append(".equivalentTo(").append(string2).append(")").toString();
}
}
public static final class Wrapper<T>
implements Serializable {
private final Equivalence<? super T> equivalence;
@Nullable
private final T reference;
private static final long serialVersionUID = 0L;
private Wrapper(Equivalence<? super T> equivalence, @Nullable T reference) {
this.equivalence = Preconditions.checkNotNull(equivalence);
this.reference = reference;
}
@Nullable
public T get() {
return this.reference;
}
public boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof Wrapper) {
Wrapper that = (Wrapper)obj;
if (this.equivalence.equals(that.equivalence)) {
Equivalence<T> equivalence = this.equivalence;
return equivalence.equivalent(this.reference, that.reference);
}
}
return false;
}
public int hashCode() {
return this.equivalence.hash(this.reference);
}
public String toString() {
String string = String.valueOf(String.valueOf(this.equivalence));
String string2 = String.valueOf(String.valueOf(this.reference));
return new StringBuilder(7 + string.length() + string2.length()).append(string).append(".wrap(").append(string2).append(")").toString();
}
}
}

View file

@ -0,0 +1,17 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.base.FinalizableReference;
import com.google.common.base.FinalizableReferenceQueue;
import java.lang.ref.PhantomReference;
public abstract class FinalizablePhantomReference<T>
extends PhantomReference<T>
implements FinalizableReference {
protected FinalizablePhantomReference(T referent, FinalizableReferenceQueue queue) {
super(referent, queue.queue);
queue.cleanUp();
}
}

View file

@ -0,0 +1,8 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
public interface FinalizableReference {
public void finalizeReferent();
}

View file

@ -0,0 +1,182 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.FinalizableReference;
import java.io.Closeable;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.ref.PhantomReference;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
public class FinalizableReferenceQueue
implements Closeable {
private static final Logger logger = Logger.getLogger(FinalizableReferenceQueue.class.getName());
private static final String FINALIZER_CLASS_NAME = "com.google.common.base.internal.Finalizer";
private static final Method startFinalizer;
final ReferenceQueue<Object> queue = new ReferenceQueue();
final PhantomReference<Object> frqRef = new PhantomReference<Object>(this, this.queue);
final boolean threadStarted;
public FinalizableReferenceQueue() {
boolean threadStarted = false;
try {
startFinalizer.invoke(null, FinalizableReference.class, this.queue, this.frqRef);
threadStarted = true;
}
catch (IllegalAccessException impossible) {
throw new AssertionError((Object)impossible);
}
catch (Throwable t) {
logger.log(Level.INFO, "Failed to start reference finalizer thread. Reference cleanup will only occur when new references are created.", t);
}
this.threadStarted = threadStarted;
}
@Override
public void close() {
this.frqRef.enqueue();
this.cleanUp();
}
void cleanUp() {
Reference<Object> reference;
if (this.threadStarted) {
return;
}
while ((reference = this.queue.poll()) != null) {
reference.clear();
try {
((FinalizableReference)((Object)reference)).finalizeReferent();
}
catch (Throwable t) {
logger.log(Level.SEVERE, "Error cleaning up after reference.", t);
}
}
}
private static Class<?> loadFinalizer(FinalizerLoader ... loaders) {
for (FinalizerLoader loader : loaders) {
Class<?> finalizer = loader.loadFinalizer();
if (finalizer == null) continue;
return finalizer;
}
throw new AssertionError();
}
static Method getStartFinalizer(Class<?> finalizer) {
try {
return finalizer.getMethod("startFinalizer", Class.class, ReferenceQueue.class, PhantomReference.class);
}
catch (NoSuchMethodException e) {
throw new AssertionError((Object)e);
}
}
static {
Class<?> finalizer = FinalizableReferenceQueue.loadFinalizer(new SystemLoader(), new DecoupledLoader(), new DirectLoader());
startFinalizer = FinalizableReferenceQueue.getStartFinalizer(finalizer);
}
static class DirectLoader
implements FinalizerLoader {
DirectLoader() {
}
@Override
public Class<?> loadFinalizer() {
try {
return Class.forName(FinalizableReferenceQueue.FINALIZER_CLASS_NAME);
}
catch (ClassNotFoundException e) {
throw new AssertionError((Object)e);
}
}
}
static class DecoupledLoader
implements FinalizerLoader {
private static final String LOADING_ERROR = "Could not load Finalizer in its own class loader.Loading Finalizer in the current class loader instead. As a result, you will not be ableto garbage collect this class loader. To support reclaiming this class loader, eitherresolve the underlying issue, or move Google Collections to your system class path.";
DecoupledLoader() {
}
@Override
public Class<?> loadFinalizer() {
try {
URLClassLoader finalizerLoader = this.newLoader(this.getBaseUrl());
return finalizerLoader.loadClass(FinalizableReferenceQueue.FINALIZER_CLASS_NAME);
}
catch (Exception e) {
logger.log(Level.WARNING, LOADING_ERROR, e);
return null;
}
}
URL getBaseUrl() throws IOException {
String finalizerPath = String.valueOf(FinalizableReferenceQueue.FINALIZER_CLASS_NAME.replace('.', '/')).concat(".class");
URL finalizerUrl = this.getClass().getClassLoader().getResource(finalizerPath);
if (finalizerUrl == null) {
throw new FileNotFoundException(finalizerPath);
}
String urlString = finalizerUrl.toString();
if (!urlString.endsWith(finalizerPath)) {
String string = String.valueOf(urlString);
throw new IOException(string.length() != 0 ? "Unsupported path style: ".concat(string) : new String("Unsupported path style: "));
}
urlString = urlString.substring(0, urlString.length() - finalizerPath.length());
return new URL(finalizerUrl, urlString);
}
URLClassLoader newLoader(URL base) {
return new URLClassLoader(new URL[]{base}, null);
}
}
static class SystemLoader
implements FinalizerLoader {
@VisibleForTesting
static boolean disabled;
SystemLoader() {
}
@Override
public Class<?> loadFinalizer() {
ClassLoader systemLoader;
if (disabled) {
return null;
}
try {
systemLoader = ClassLoader.getSystemClassLoader();
}
catch (SecurityException e) {
logger.info("Not allowed to access system class loader.");
return null;
}
if (systemLoader != null) {
try {
return systemLoader.loadClass(FinalizableReferenceQueue.FINALIZER_CLASS_NAME);
}
catch (ClassNotFoundException e) {
return null;
}
}
return null;
}
}
static interface FinalizerLoader {
@Nullable
public Class<?> loadFinalizer();
}
}

View file

@ -0,0 +1,17 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.base.FinalizableReference;
import com.google.common.base.FinalizableReferenceQueue;
import java.lang.ref.SoftReference;
public abstract class FinalizableSoftReference<T>
extends SoftReference<T>
implements FinalizableReference {
protected FinalizableSoftReference(T referent, FinalizableReferenceQueue queue) {
super(referent, queue.queue);
queue.cleanUp();
}
}

View file

@ -0,0 +1,17 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.base.FinalizableReference;
import com.google.common.base.FinalizableReferenceQueue;
import java.lang.ref.WeakReference;
public abstract class FinalizableWeakReference<T>
extends WeakReference<T>
implements FinalizableReference {
protected FinalizableWeakReference(T referent, FinalizableReferenceQueue queue) {
super(referent, queue.queue);
queue.cleanUp();
}
}

View file

@ -0,0 +1,15 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.GwtCompatible;
import javax.annotation.Nullable;
@GwtCompatible
public interface Function<F, T> {
@Nullable
public T apply(@Nullable F var1);
public boolean equals(@Nullable Object var1);
}

View file

@ -0,0 +1,59 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Equivalence;
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import java.io.Serializable;
import javax.annotation.Nullable;
@Beta
@GwtCompatible
final class FunctionalEquivalence<F, T>
extends Equivalence<F>
implements Serializable {
private static final long serialVersionUID = 0L;
private final Function<F, ? extends T> function;
private final Equivalence<T> resultEquivalence;
FunctionalEquivalence(Function<F, ? extends T> function, Equivalence<T> resultEquivalence) {
this.function = Preconditions.checkNotNull(function);
this.resultEquivalence = Preconditions.checkNotNull(resultEquivalence);
}
@Override
protected boolean doEquivalent(F a, F b) {
return this.resultEquivalence.equivalent(this.function.apply(a), this.function.apply(b));
}
@Override
protected int doHash(F a) {
return this.resultEquivalence.hash(this.function.apply(a));
}
public boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof FunctionalEquivalence) {
FunctionalEquivalence that = (FunctionalEquivalence)obj;
return this.function.equals(that.function) && this.resultEquivalence.equals(that.resultEquivalence);
}
return false;
}
public int hashCode() {
return Objects.hashCode(this.function, this.resultEquivalence);
}
public String toString() {
String string = String.valueOf(String.valueOf(this.resultEquivalence));
String string2 = String.valueOf(String.valueOf(this.function));
return new StringBuilder(13 + string.length() + string2.length()).append(string).append(".onResultOf(").append(string2).append(")").toString();
}
}

View file

@ -0,0 +1,299 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import java.io.Serializable;
import java.util.Map;
import javax.annotation.Nullable;
@GwtCompatible
public final class Functions {
private Functions() {
}
public static Function<Object, String> toStringFunction() {
return ToStringFunction.INSTANCE;
}
public static <E> Function<E, E> identity() {
return IdentityFunction.INSTANCE;
}
public static <K, V> Function<K, V> forMap(Map<K, V> map) {
return new FunctionForMapNoDefault<K, V>(map);
}
public static <K, V> Function<K, V> forMap(Map<K, ? extends V> map, @Nullable V defaultValue) {
return new ForMapWithDefault<K, V>(map, defaultValue);
}
public static <A, B, C> Function<A, C> compose(Function<B, C> g, Function<A, ? extends B> f) {
return new FunctionComposition<A, B, C>(g, f);
}
public static <T> Function<T, Boolean> forPredicate(Predicate<T> predicate) {
return new PredicateFunction(predicate);
}
public static <E> Function<Object, E> constant(@Nullable E value) {
return new ConstantFunction<E>(value);
}
@Beta
public static <T> Function<Object, T> forSupplier(Supplier<T> supplier) {
return new SupplierFunction(supplier);
}
private static class SupplierFunction<T>
implements Function<Object, T>,
Serializable {
private final Supplier<T> supplier;
private static final long serialVersionUID = 0L;
private SupplierFunction(Supplier<T> supplier) {
this.supplier = Preconditions.checkNotNull(supplier);
}
@Override
public T apply(@Nullable Object input) {
return this.supplier.get();
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof SupplierFunction) {
SupplierFunction that = (SupplierFunction)obj;
return this.supplier.equals(that.supplier);
}
return false;
}
public int hashCode() {
return this.supplier.hashCode();
}
public String toString() {
String string = String.valueOf(String.valueOf(this.supplier));
return new StringBuilder(13 + string.length()).append("forSupplier(").append(string).append(")").toString();
}
}
private static class ConstantFunction<E>
implements Function<Object, E>,
Serializable {
private final E value;
private static final long serialVersionUID = 0L;
public ConstantFunction(@Nullable E value) {
this.value = value;
}
@Override
public E apply(@Nullable Object from) {
return this.value;
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof ConstantFunction) {
ConstantFunction that = (ConstantFunction)obj;
return Objects.equal(this.value, that.value);
}
return false;
}
public int hashCode() {
return this.value == null ? 0 : this.value.hashCode();
}
public String toString() {
String string = String.valueOf(String.valueOf(this.value));
return new StringBuilder(10 + string.length()).append("constant(").append(string).append(")").toString();
}
}
private static class PredicateFunction<T>
implements Function<T, Boolean>,
Serializable {
private final Predicate<T> predicate;
private static final long serialVersionUID = 0L;
private PredicateFunction(Predicate<T> predicate) {
this.predicate = Preconditions.checkNotNull(predicate);
}
@Override
public Boolean apply(@Nullable T t) {
return this.predicate.apply(t);
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof PredicateFunction) {
PredicateFunction that = (PredicateFunction)obj;
return this.predicate.equals(that.predicate);
}
return false;
}
public int hashCode() {
return this.predicate.hashCode();
}
public String toString() {
String string = String.valueOf(String.valueOf(this.predicate));
return new StringBuilder(14 + string.length()).append("forPredicate(").append(string).append(")").toString();
}
}
private static class FunctionComposition<A, B, C>
implements Function<A, C>,
Serializable {
private final Function<B, C> g;
private final Function<A, ? extends B> f;
private static final long serialVersionUID = 0L;
public FunctionComposition(Function<B, C> g, Function<A, ? extends B> f) {
this.g = Preconditions.checkNotNull(g);
this.f = Preconditions.checkNotNull(f);
}
@Override
public C apply(@Nullable A a) {
return this.g.apply(this.f.apply(a));
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof FunctionComposition) {
FunctionComposition that = (FunctionComposition)obj;
return this.f.equals(that.f) && this.g.equals(that.g);
}
return false;
}
public int hashCode() {
return this.f.hashCode() ^ this.g.hashCode();
}
public String toString() {
String string = String.valueOf(String.valueOf(this.g));
String string2 = String.valueOf(String.valueOf(this.f));
return new StringBuilder(2 + string.length() + string2.length()).append(string).append("(").append(string2).append(")").toString();
}
}
private static class ForMapWithDefault<K, V>
implements Function<K, V>,
Serializable {
final Map<K, ? extends V> map;
final V defaultValue;
private static final long serialVersionUID = 0L;
ForMapWithDefault(Map<K, ? extends V> map, @Nullable V defaultValue) {
this.map = Preconditions.checkNotNull(map);
this.defaultValue = defaultValue;
}
@Override
public V apply(@Nullable K key) {
V result = this.map.get(key);
return result != null || this.map.containsKey(key) ? result : this.defaultValue;
}
@Override
public boolean equals(@Nullable Object o) {
if (o instanceof ForMapWithDefault) {
ForMapWithDefault that = (ForMapWithDefault)o;
return this.map.equals(that.map) && Objects.equal(this.defaultValue, that.defaultValue);
}
return false;
}
public int hashCode() {
return Objects.hashCode(this.map, this.defaultValue);
}
public String toString() {
String string = String.valueOf(String.valueOf(this.map));
String string2 = String.valueOf(String.valueOf(this.defaultValue));
return new StringBuilder(23 + string.length() + string2.length()).append("forMap(").append(string).append(", defaultValue=").append(string2).append(")").toString();
}
}
private static class FunctionForMapNoDefault<K, V>
implements Function<K, V>,
Serializable {
final Map<K, V> map;
private static final long serialVersionUID = 0L;
FunctionForMapNoDefault(Map<K, V> map) {
this.map = Preconditions.checkNotNull(map);
}
@Override
public V apply(@Nullable K key) {
V result = this.map.get(key);
Preconditions.checkArgument(result != null || this.map.containsKey(key), "Key '%s' not present in map", key);
return result;
}
@Override
public boolean equals(@Nullable Object o) {
if (o instanceof FunctionForMapNoDefault) {
FunctionForMapNoDefault that = (FunctionForMapNoDefault)o;
return this.map.equals(that.map);
}
return false;
}
public int hashCode() {
return this.map.hashCode();
}
public String toString() {
String string = String.valueOf(String.valueOf(this.map));
return new StringBuilder(8 + string.length()).append("forMap(").append(string).append(")").toString();
}
}
private static enum IdentityFunction implements Function<Object, Object>
{
INSTANCE;
@Override
@Nullable
public Object apply(@Nullable Object o) {
return o;
}
public String toString() {
return "identity";
}
}
private static enum ToStringFunction implements Function<Object, String>
{
INSTANCE;
@Override
public String apply(Object o) {
Preconditions.checkNotNull(o);
return o.toString();
}
public String toString() {
return "toString";
}
}
}

View file

@ -0,0 +1,267 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Preconditions;
import java.io.IOException;
import java.util.AbstractList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
@GwtCompatible
public class Joiner {
private final String separator;
public static Joiner on(String separator) {
return new Joiner(separator);
}
public static Joiner on(char separator) {
return new Joiner(String.valueOf(separator));
}
private Joiner(String separator) {
this.separator = Preconditions.checkNotNull(separator);
}
private Joiner(Joiner prototype) {
this.separator = prototype.separator;
}
public <A extends Appendable> A appendTo(A appendable, Iterable<?> parts) throws IOException {
return this.appendTo(appendable, parts.iterator());
}
public <A extends Appendable> A appendTo(A appendable, Iterator<?> parts) throws IOException {
Preconditions.checkNotNull(appendable);
if (parts.hasNext()) {
appendable.append(this.toString(parts.next()));
while (parts.hasNext()) {
appendable.append(this.separator);
appendable.append(this.toString(parts.next()));
}
}
return appendable;
}
public final <A extends Appendable> A appendTo(A appendable, Object[] parts) throws IOException {
return this.appendTo(appendable, Arrays.asList(parts));
}
public final <A extends Appendable> A appendTo(A appendable, @Nullable Object first, @Nullable Object second, Object ... rest) throws IOException {
return this.appendTo(appendable, Joiner.iterable(first, second, rest));
}
public final StringBuilder appendTo(StringBuilder builder, Iterable<?> parts) {
return this.appendTo(builder, parts.iterator());
}
public final StringBuilder appendTo(StringBuilder builder, Iterator<?> parts) {
try {
this.appendTo((Appendable)builder, parts);
}
catch (IOException impossible) {
throw new AssertionError((Object)impossible);
}
return builder;
}
public final StringBuilder appendTo(StringBuilder builder, Object[] parts) {
return this.appendTo(builder, (Iterable<?>)Arrays.asList(parts));
}
public final StringBuilder appendTo(StringBuilder builder, @Nullable Object first, @Nullable Object second, Object ... rest) {
return this.appendTo(builder, Joiner.iterable(first, second, rest));
}
public final String join(Iterable<?> parts) {
return this.join(parts.iterator());
}
public final String join(Iterator<?> parts) {
return this.appendTo(new StringBuilder(), parts).toString();
}
public final String join(Object[] parts) {
return this.join(Arrays.asList(parts));
}
public final String join(@Nullable Object first, @Nullable Object second, Object ... rest) {
return this.join(Joiner.iterable(first, second, rest));
}
@CheckReturnValue
public Joiner useForNull(final String nullText) {
Preconditions.checkNotNull(nullText);
return new Joiner(this){
@Override
CharSequence toString(@Nullable Object part) {
return part == null ? nullText : Joiner.this.toString(part);
}
@Override
public Joiner useForNull(String nullText2) {
throw new UnsupportedOperationException("already specified useForNull");
}
@Override
public Joiner skipNulls() {
throw new UnsupportedOperationException("already specified useForNull");
}
};
}
@CheckReturnValue
public Joiner skipNulls() {
return new Joiner(this){
@Override
public <A extends Appendable> A appendTo(A appendable, Iterator<?> parts) throws IOException {
Object part;
Preconditions.checkNotNull(appendable, "appendable");
Preconditions.checkNotNull(parts, "parts");
while (parts.hasNext()) {
part = parts.next();
if (part == null) continue;
appendable.append(Joiner.this.toString(part));
break;
}
while (parts.hasNext()) {
part = parts.next();
if (part == null) continue;
appendable.append(Joiner.this.separator);
appendable.append(Joiner.this.toString(part));
}
return appendable;
}
@Override
public Joiner useForNull(String nullText) {
throw new UnsupportedOperationException("already specified skipNulls");
}
@Override
public MapJoiner withKeyValueSeparator(String kvs) {
throw new UnsupportedOperationException("can't use .skipNulls() with maps");
}
};
}
@CheckReturnValue
public MapJoiner withKeyValueSeparator(String keyValueSeparator) {
return new MapJoiner(this, keyValueSeparator);
}
CharSequence toString(Object part) {
Preconditions.checkNotNull(part);
return part instanceof CharSequence ? (CharSequence)part : part.toString();
}
private static Iterable<Object> iterable(final Object first, final Object second, final Object[] rest) {
Preconditions.checkNotNull(rest);
return new AbstractList<Object>(){
@Override
public int size() {
return rest.length + 2;
}
@Override
public Object get(int index) {
switch (index) {
case 0: {
return first;
}
case 1: {
return second;
}
}
return rest[index - 2];
}
};
}
public static final class MapJoiner {
private final Joiner joiner;
private final String keyValueSeparator;
private MapJoiner(Joiner joiner, String keyValueSeparator) {
this.joiner = joiner;
this.keyValueSeparator = Preconditions.checkNotNull(keyValueSeparator);
}
public <A extends Appendable> A appendTo(A appendable, Map<?, ?> map) throws IOException {
return this.appendTo(appendable, map.entrySet());
}
public StringBuilder appendTo(StringBuilder builder, Map<?, ?> map) {
return this.appendTo(builder, (Iterable<? extends Map.Entry<?, ?>>)map.entrySet());
}
public String join(Map<?, ?> map) {
return this.join(map.entrySet());
}
@Beta
public <A extends Appendable> A appendTo(A appendable, Iterable<? extends Map.Entry<?, ?>> entries) throws IOException {
return this.appendTo(appendable, entries.iterator());
}
@Beta
public <A extends Appendable> A appendTo(A appendable, Iterator<? extends Map.Entry<?, ?>> parts) throws IOException {
Preconditions.checkNotNull(appendable);
if (parts.hasNext()) {
Map.Entry<?, ?> entry = parts.next();
appendable.append(this.joiner.toString(entry.getKey()));
appendable.append(this.keyValueSeparator);
appendable.append(this.joiner.toString(entry.getValue()));
while (parts.hasNext()) {
appendable.append(this.joiner.separator);
Map.Entry<?, ?> e = parts.next();
appendable.append(this.joiner.toString(e.getKey()));
appendable.append(this.keyValueSeparator);
appendable.append(this.joiner.toString(e.getValue()));
}
}
return appendable;
}
@Beta
public StringBuilder appendTo(StringBuilder builder, Iterable<? extends Map.Entry<?, ?>> entries) {
return this.appendTo(builder, entries.iterator());
}
@Beta
public StringBuilder appendTo(StringBuilder builder, Iterator<? extends Map.Entry<?, ?>> entries) {
try {
this.appendTo((Appendable)builder, entries);
}
catch (IOException impossible) {
throw new AssertionError((Object)impossible);
}
return builder;
}
@Beta
public String join(Iterable<? extends Map.Entry<?, ?>> entries) {
return this.join(entries.iterator());
}
@Beta
public String join(Iterator<? extends Map.Entry<?, ?>> entries) {
return this.appendTo(new StringBuilder(), entries).toString();
}
@CheckReturnValue
public MapJoiner useForNull(String nullText) {
return new MapJoiner(this.joiner.useForNull(nullText), this.keyValueSeparator);
}
}
}

View file

@ -0,0 +1,160 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Preconditions;
import javax.annotation.Nullable;
@GwtCompatible
public final class MoreObjects {
public static <T> T firstNonNull(@Nullable T first, @Nullable T second) {
return first != null ? first : Preconditions.checkNotNull(second);
}
public static ToStringHelper toStringHelper(Object self) {
return new ToStringHelper(MoreObjects.simpleName(self.getClass()));
}
public static ToStringHelper toStringHelper(Class<?> clazz) {
return new ToStringHelper(MoreObjects.simpleName(clazz));
}
public static ToStringHelper toStringHelper(String className) {
return new ToStringHelper(className);
}
static String simpleName(Class<?> clazz) {
String name = clazz.getName();
int start = (name = name.replaceAll("\\$[0-9]+", "\\$")).lastIndexOf(36);
if (start == -1) {
start = name.lastIndexOf(46);
}
return name.substring(start + 1);
}
private MoreObjects() {
}
public static final class ToStringHelper {
private final String className;
private ValueHolder holderHead;
private ValueHolder holderTail;
private boolean omitNullValues;
private ToStringHelper(String className) {
this.holderTail = this.holderHead = new ValueHolder();
this.omitNullValues = false;
this.className = Preconditions.checkNotNull(className);
}
public ToStringHelper omitNullValues() {
this.omitNullValues = true;
return this;
}
public ToStringHelper add(String name, @Nullable Object value) {
return this.addHolder(name, value);
}
public ToStringHelper add(String name, boolean value) {
return this.addHolder(name, String.valueOf(value));
}
public ToStringHelper add(String name, char value) {
return this.addHolder(name, String.valueOf(value));
}
public ToStringHelper add(String name, double value) {
return this.addHolder(name, String.valueOf(value));
}
public ToStringHelper add(String name, float value) {
return this.addHolder(name, String.valueOf(value));
}
public ToStringHelper add(String name, int value) {
return this.addHolder(name, String.valueOf(value));
}
public ToStringHelper add(String name, long value) {
return this.addHolder(name, String.valueOf(value));
}
public ToStringHelper addValue(@Nullable Object value) {
return this.addHolder(value);
}
public ToStringHelper addValue(boolean value) {
return this.addHolder(String.valueOf(value));
}
public ToStringHelper addValue(char value) {
return this.addHolder(String.valueOf(value));
}
public ToStringHelper addValue(double value) {
return this.addHolder(String.valueOf(value));
}
public ToStringHelper addValue(float value) {
return this.addHolder(String.valueOf(value));
}
public ToStringHelper addValue(int value) {
return this.addHolder(String.valueOf(value));
}
public ToStringHelper addValue(long value) {
return this.addHolder(String.valueOf(value));
}
public String toString() {
boolean omitNullValuesSnapshot = this.omitNullValues;
String nextSeparator = "";
StringBuilder builder = new StringBuilder(32).append(this.className).append('{');
ValueHolder valueHolder = this.holderHead.next;
while (valueHolder != null) {
if (!omitNullValuesSnapshot || valueHolder.value != null) {
builder.append(nextSeparator);
nextSeparator = ", ";
if (valueHolder.name != null) {
builder.append(valueHolder.name).append('=');
}
builder.append(valueHolder.value);
}
valueHolder = valueHolder.next;
}
return builder.append('}').toString();
}
private ValueHolder addHolder() {
ValueHolder valueHolder;
this.holderTail = this.holderTail.next = (valueHolder = new ValueHolder());
return valueHolder;
}
private ToStringHelper addHolder(@Nullable Object value) {
ValueHolder valueHolder = this.addHolder();
valueHolder.value = value;
return this;
}
private ToStringHelper addHolder(String name, @Nullable Object value) {
ValueHolder valueHolder = this.addHolder();
valueHolder.value = value;
valueHolder.name = Preconditions.checkNotNull(name);
return this;
}
private static final class ValueHolder {
String name;
Object value;
ValueHolder next;
private ValueHolder() {
}
}
}
}

View file

@ -0,0 +1,168 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import java.util.Arrays;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
@GwtCompatible
public final class Objects {
private Objects() {
}
@CheckReturnValue
public static boolean equal(@Nullable Object a, @Nullable Object b) {
return a == b || a != null && a.equals(b);
}
public static int hashCode(Object ... objects) {
return Arrays.hashCode(objects);
}
@Deprecated
public static ToStringHelper toStringHelper(Object self) {
return new ToStringHelper(MoreObjects.simpleName(self.getClass()));
}
@Deprecated
public static ToStringHelper toStringHelper(Class<?> clazz) {
return new ToStringHelper(MoreObjects.simpleName(clazz));
}
@Deprecated
public static ToStringHelper toStringHelper(String className) {
return new ToStringHelper(className);
}
@Deprecated
public static <T> T firstNonNull(@Nullable T first, @Nullable T second) {
return MoreObjects.firstNonNull(first, second);
}
@Deprecated
public static final class ToStringHelper {
private final String className;
private ValueHolder holderHead;
private ValueHolder holderTail;
private boolean omitNullValues;
private ToStringHelper(String className) {
this.holderTail = this.holderHead = new ValueHolder();
this.omitNullValues = false;
this.className = Preconditions.checkNotNull(className);
}
public ToStringHelper omitNullValues() {
this.omitNullValues = true;
return this;
}
public ToStringHelper add(String name, @Nullable Object value) {
return this.addHolder(name, value);
}
public ToStringHelper add(String name, boolean value) {
return this.addHolder(name, String.valueOf(value));
}
public ToStringHelper add(String name, char value) {
return this.addHolder(name, String.valueOf(value));
}
public ToStringHelper add(String name, double value) {
return this.addHolder(name, String.valueOf(value));
}
public ToStringHelper add(String name, float value) {
return this.addHolder(name, String.valueOf(value));
}
public ToStringHelper add(String name, int value) {
return this.addHolder(name, String.valueOf(value));
}
public ToStringHelper add(String name, long value) {
return this.addHolder(name, String.valueOf(value));
}
public ToStringHelper addValue(@Nullable Object value) {
return this.addHolder(value);
}
public ToStringHelper addValue(boolean value) {
return this.addHolder(String.valueOf(value));
}
public ToStringHelper addValue(char value) {
return this.addHolder(String.valueOf(value));
}
public ToStringHelper addValue(double value) {
return this.addHolder(String.valueOf(value));
}
public ToStringHelper addValue(float value) {
return this.addHolder(String.valueOf(value));
}
public ToStringHelper addValue(int value) {
return this.addHolder(String.valueOf(value));
}
public ToStringHelper addValue(long value) {
return this.addHolder(String.valueOf(value));
}
public String toString() {
boolean omitNullValuesSnapshot = this.omitNullValues;
String nextSeparator = "";
StringBuilder builder = new StringBuilder(32).append(this.className).append('{');
ValueHolder valueHolder = this.holderHead.next;
while (valueHolder != null) {
if (!omitNullValuesSnapshot || valueHolder.value != null) {
builder.append(nextSeparator);
nextSeparator = ", ";
if (valueHolder.name != null) {
builder.append(valueHolder.name).append('=');
}
builder.append(valueHolder.value);
}
valueHolder = valueHolder.next;
}
return builder.append('}').toString();
}
private ValueHolder addHolder() {
ValueHolder valueHolder;
this.holderTail = this.holderTail.next = (valueHolder = new ValueHolder());
return valueHolder;
}
private ToStringHelper addHolder(@Nullable Object value) {
ValueHolder valueHolder = this.addHolder();
valueHolder.value = value;
return this;
}
private ToStringHelper addHolder(String name, @Nullable Object value) {
ValueHolder valueHolder = this.addHolder();
valueHolder.value = value;
valueHolder.name = Preconditions.checkNotNull(name);
return this;
}
private static final class ValueHolder {
String name;
Object value;
ValueHolder next;
private ValueHolder() {
}
}
}
}

View file

@ -0,0 +1,89 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Absent;
import com.google.common.base.AbstractIterator;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.base.Present;
import com.google.common.base.Supplier;
import java.io.Serializable;
import java.util.Iterator;
import java.util.Set;
import javax.annotation.Nullable;
@GwtCompatible(serializable=true)
public abstract class Optional<T>
implements Serializable {
private static final long serialVersionUID = 0L;
public static <T> Optional<T> absent() {
return Absent.withType();
}
public static <T> Optional<T> of(T reference) {
return new Present<T>(Preconditions.checkNotNull(reference));
}
public static <T> Optional<T> fromNullable(@Nullable T nullableReference) {
return nullableReference == null ? Optional.absent() : new Present<T>(nullableReference);
}
Optional() {
}
public abstract boolean isPresent();
public abstract T get();
public abstract T or(T var1);
public abstract Optional<T> or(Optional<? extends T> var1);
@Beta
public abstract T or(Supplier<? extends T> var1);
@Nullable
public abstract T orNull();
public abstract Set<T> asSet();
public abstract <V> Optional<V> transform(Function<? super T, V> var1);
public abstract boolean equals(@Nullable Object var1);
public abstract int hashCode();
public abstract String toString();
@Beta
public static <T> Iterable<T> presentInstances(final Iterable<? extends Optional<? extends T>> optionals) {
Preconditions.checkNotNull(optionals);
return new Iterable<T>(){
@Override
public Iterator<T> iterator() {
return new AbstractIterator<T>(){
private final Iterator<? extends Optional<? extends T>> iterator;
{
this.iterator = Preconditions.checkNotNull(optionals.iterator());
}
@Override
protected T computeNext() {
while (this.iterator.hasNext()) {
Optional optional = this.iterator.next();
if (!optional.isPresent()) continue;
return optional.get();
}
return this.endOfData();
}
};
}
};
}
}

View file

@ -0,0 +1,60 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Equivalence;
import com.google.common.base.Preconditions;
import java.io.Serializable;
import java.util.Iterator;
import javax.annotation.Nullable;
@GwtCompatible(serializable=true)
final class PairwiseEquivalence<T>
extends Equivalence<Iterable<T>>
implements Serializable {
final Equivalence<? super T> elementEquivalence;
private static final long serialVersionUID = 1L;
PairwiseEquivalence(Equivalence<? super T> elementEquivalence) {
this.elementEquivalence = Preconditions.checkNotNull(elementEquivalence);
}
@Override
protected boolean doEquivalent(Iterable<T> iterableA, Iterable<T> iterableB) {
Iterator<T> iteratorA = iterableA.iterator();
Iterator<T> iteratorB = iterableB.iterator();
while (iteratorA.hasNext() && iteratorB.hasNext()) {
if (this.elementEquivalence.equivalent(iteratorA.next(), iteratorB.next())) continue;
return false;
}
return !iteratorA.hasNext() && !iteratorB.hasNext();
}
@Override
protected int doHash(Iterable<T> iterable) {
int hash = 78721;
for (T element : iterable) {
hash = hash * 24943 + this.elementEquivalence.hash(element);
}
return hash;
}
public boolean equals(@Nullable Object object) {
if (object instanceof PairwiseEquivalence) {
PairwiseEquivalence that = (PairwiseEquivalence)object;
return this.elementEquivalence.equals(that.elementEquivalence);
}
return false;
}
public int hashCode() {
return this.elementEquivalence.hashCode() ^ 0x46A3EB07;
}
public String toString() {
String string = String.valueOf(String.valueOf(this.elementEquivalence));
return new StringBuilder(11 + string.length()).append(string).append(".pairwise()").toString();
}
}

View file

@ -0,0 +1,29 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.CharMatcher;
import com.google.common.base.Enums;
import com.google.common.base.Optional;
import java.lang.ref.WeakReference;
@GwtCompatible(emulated=true)
final class Platform {
private Platform() {
}
static long systemNanoTime() {
return System.nanoTime();
}
static CharMatcher precomputeCharMatcher(CharMatcher matcher) {
return matcher.precomputedInternal();
}
static <T extends Enum<T>> Optional<T> getEnumIfPresent(Class<T> enumClass, String value) {
WeakReference<Enum<?>> ref = Enums.getEnumConstants(enumClass).get(value);
return ref == null ? Optional.absent() : Optional.of(enumClass.cast(ref.get()));
}
}

View file

@ -0,0 +1,154 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.GwtCompatible;
import javax.annotation.Nullable;
@GwtCompatible
public final class Preconditions {
private Preconditions() {
}
public static void checkArgument(boolean expression) {
if (!expression) {
throw new IllegalArgumentException();
}
}
public static void checkArgument(boolean expression, @Nullable Object errorMessage) {
if (!expression) {
throw new IllegalArgumentException(String.valueOf(errorMessage));
}
}
public static void checkArgument(boolean expression, @Nullable String errorMessageTemplate, Object ... errorMessageArgs) {
if (!expression) {
throw new IllegalArgumentException(Preconditions.format(errorMessageTemplate, errorMessageArgs));
}
}
public static void checkState(boolean expression) {
if (!expression) {
throw new IllegalStateException();
}
}
public static void checkState(boolean expression, @Nullable Object errorMessage) {
if (!expression) {
throw new IllegalStateException(String.valueOf(errorMessage));
}
}
public static void checkState(boolean expression, @Nullable String errorMessageTemplate, Object ... errorMessageArgs) {
if (!expression) {
throw new IllegalStateException(Preconditions.format(errorMessageTemplate, errorMessageArgs));
}
}
public static <T> T checkNotNull(T reference) {
if (reference == null) {
throw new NullPointerException();
}
return reference;
}
public static <T> T checkNotNull(T reference, @Nullable Object errorMessage) {
if (reference == null) {
throw new NullPointerException(String.valueOf(errorMessage));
}
return reference;
}
public static <T> T checkNotNull(T reference, @Nullable String errorMessageTemplate, Object ... errorMessageArgs) {
if (reference == null) {
throw new NullPointerException(Preconditions.format(errorMessageTemplate, errorMessageArgs));
}
return reference;
}
public static int checkElementIndex(int index, int size) {
return Preconditions.checkElementIndex(index, size, "index");
}
public static int checkElementIndex(int index, int size, @Nullable String desc) {
if (index < 0 || index >= size) {
throw new IndexOutOfBoundsException(Preconditions.badElementIndex(index, size, desc));
}
return index;
}
private static String badElementIndex(int index, int size, String desc) {
if (index < 0) {
return Preconditions.format("%s (%s) must not be negative", desc, index);
}
if (size < 0) {
int n = size;
throw new IllegalArgumentException(new StringBuilder(26).append("negative size: ").append(n).toString());
}
return Preconditions.format("%s (%s) must be less than size (%s)", desc, index, size);
}
public static int checkPositionIndex(int index, int size) {
return Preconditions.checkPositionIndex(index, size, "index");
}
public static int checkPositionIndex(int index, int size, @Nullable String desc) {
if (index < 0 || index > size) {
throw new IndexOutOfBoundsException(Preconditions.badPositionIndex(index, size, desc));
}
return index;
}
private static String badPositionIndex(int index, int size, String desc) {
if (index < 0) {
return Preconditions.format("%s (%s) must not be negative", desc, index);
}
if (size < 0) {
int n = size;
throw new IllegalArgumentException(new StringBuilder(26).append("negative size: ").append(n).toString());
}
return Preconditions.format("%s (%s) must not be greater than size (%s)", desc, index, size);
}
public static void checkPositionIndexes(int start, int end, int size) {
if (start < 0 || end < start || end > size) {
throw new IndexOutOfBoundsException(Preconditions.badPositionIndexes(start, end, size));
}
}
private static String badPositionIndexes(int start, int end, int size) {
if (start < 0 || start > size) {
return Preconditions.badPositionIndex(start, size, "start index");
}
if (end < 0 || end > size) {
return Preconditions.badPositionIndex(end, size, "end index");
}
return Preconditions.format("end index (%s) must not be less than start index (%s)", end, start);
}
static String format(String template, Object ... args) {
int placeholderStart;
template = String.valueOf(template);
StringBuilder builder = new StringBuilder(template.length() + 16 * args.length);
int templateStart = 0;
int i = 0;
while (i < args.length && (placeholderStart = template.indexOf("%s", templateStart)) != -1) {
builder.append(template.substring(templateStart, placeholderStart));
builder.append(args[i++]);
templateStart = placeholderStart + 2;
}
builder.append(template.substring(templateStart));
if (i < args.length) {
builder.append(" [");
builder.append(args[i++]);
while (i < args.length) {
builder.append(", ");
builder.append(args[i++]);
}
builder.append(']');
}
return builder.toString();
}
}

View file

@ -0,0 +1,14 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.GwtCompatible;
import javax.annotation.Nullable;
@GwtCompatible
public interface Predicate<T> {
public boolean apply(@Nullable T var1);
public boolean equals(@Nullable Object var1);
}

View file

@ -0,0 +1,526 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
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.Joiner;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
@GwtCompatible(emulated=true)
public final class Predicates {
private static final Joiner COMMA_JOINER = Joiner.on(',');
private Predicates() {
}
@GwtCompatible(serializable=true)
public static <T> Predicate<T> alwaysTrue() {
return ObjectPredicate.ALWAYS_TRUE.withNarrowedType();
}
@GwtCompatible(serializable=true)
public static <T> Predicate<T> alwaysFalse() {
return ObjectPredicate.ALWAYS_FALSE.withNarrowedType();
}
@GwtCompatible(serializable=true)
public static <T> Predicate<T> isNull() {
return ObjectPredicate.IS_NULL.withNarrowedType();
}
@GwtCompatible(serializable=true)
public static <T> Predicate<T> notNull() {
return ObjectPredicate.NOT_NULL.withNarrowedType();
}
public static <T> Predicate<T> not(Predicate<T> predicate) {
return new NotPredicate<T>(predicate);
}
public static <T> Predicate<T> and(Iterable<? extends Predicate<? super T>> components) {
return new AndPredicate(Predicates.defensiveCopy(components));
}
public static <T> Predicate<T> and(Predicate<? super T> ... components) {
return new AndPredicate(Predicates.defensiveCopy(components));
}
public static <T> Predicate<T> and(Predicate<? super T> first, Predicate<? super T> second) {
return new AndPredicate(Predicates.asList(Preconditions.checkNotNull(first), Preconditions.checkNotNull(second)));
}
public static <T> Predicate<T> or(Iterable<? extends Predicate<? super T>> components) {
return new OrPredicate(Predicates.defensiveCopy(components));
}
public static <T> Predicate<T> or(Predicate<? super T> ... components) {
return new OrPredicate(Predicates.defensiveCopy(components));
}
public static <T> Predicate<T> or(Predicate<? super T> first, Predicate<? super T> second) {
return new OrPredicate(Predicates.asList(Preconditions.checkNotNull(first), Preconditions.checkNotNull(second)));
}
public static <T> Predicate<T> equalTo(@Nullable T target) {
return target == null ? Predicates.isNull() : new IsEqualToPredicate(target);
}
@GwtIncompatible(value="Class.isInstance")
public static Predicate<Object> instanceOf(Class<?> clazz) {
return new InstanceOfPredicate(clazz);
}
@GwtIncompatible(value="Class.isAssignableFrom")
@Beta
public static Predicate<Class<?>> assignableFrom(Class<?> clazz) {
return new AssignableFromPredicate(clazz);
}
public static <T> Predicate<T> in(Collection<? extends T> target) {
return new InPredicate(target);
}
public static <A, B> Predicate<A> compose(Predicate<B> predicate, Function<A, ? extends B> function) {
return new CompositionPredicate(predicate, function);
}
@GwtIncompatible(value="java.util.regex.Pattern")
public static Predicate<CharSequence> containsPattern(String pattern) {
return new ContainsPatternFromStringPredicate(pattern);
}
@GwtIncompatible(value="java.util.regex.Pattern")
public static Predicate<CharSequence> contains(Pattern pattern) {
return new ContainsPatternPredicate(pattern);
}
private static <T> List<Predicate<? super T>> asList(Predicate<? super T> first, Predicate<? super T> second) {
return Arrays.asList(first, second);
}
private static <T> List<T> defensiveCopy(T ... array) {
return Predicates.defensiveCopy(Arrays.asList(array));
}
static <T> List<T> defensiveCopy(Iterable<T> iterable) {
ArrayList<T> list = new ArrayList<T>();
for (T element : iterable) {
list.add(Preconditions.checkNotNull(element));
}
return list;
}
@GwtIncompatible(value="Only used by other GWT-incompatible code.")
private static class ContainsPatternFromStringPredicate
extends ContainsPatternPredicate {
private static final long serialVersionUID = 0L;
ContainsPatternFromStringPredicate(String string) {
super(Pattern.compile(string));
}
@Override
public String toString() {
String string = String.valueOf(String.valueOf(this.pattern.pattern()));
return new StringBuilder(28 + string.length()).append("Predicates.containsPattern(").append(string).append(")").toString();
}
}
@GwtIncompatible(value="Only used by other GWT-incompatible code.")
private static class ContainsPatternPredicate
implements Predicate<CharSequence>,
Serializable {
final Pattern pattern;
private static final long serialVersionUID = 0L;
ContainsPatternPredicate(Pattern pattern) {
this.pattern = Preconditions.checkNotNull(pattern);
}
@Override
public boolean apply(CharSequence t) {
return this.pattern.matcher(t).find();
}
public int hashCode() {
return Objects.hashCode(this.pattern.pattern(), this.pattern.flags());
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof ContainsPatternPredicate) {
ContainsPatternPredicate that = (ContainsPatternPredicate)obj;
return Objects.equal(this.pattern.pattern(), that.pattern.pattern()) && Objects.equal(this.pattern.flags(), that.pattern.flags());
}
return false;
}
public String toString() {
String patternString = Objects.toStringHelper(this.pattern).add("pattern", this.pattern.pattern()).add("pattern.flags", this.pattern.flags()).toString();
String string = String.valueOf(String.valueOf(patternString));
return new StringBuilder(21 + string.length()).append("Predicates.contains(").append(string).append(")").toString();
}
}
private static class CompositionPredicate<A, B>
implements Predicate<A>,
Serializable {
final Predicate<B> p;
final Function<A, ? extends B> f;
private static final long serialVersionUID = 0L;
private CompositionPredicate(Predicate<B> p, Function<A, ? extends B> f) {
this.p = Preconditions.checkNotNull(p);
this.f = Preconditions.checkNotNull(f);
}
@Override
public boolean apply(@Nullable A a) {
return this.p.apply(this.f.apply(a));
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof CompositionPredicate) {
CompositionPredicate that = (CompositionPredicate)obj;
return this.f.equals(that.f) && this.p.equals(that.p);
}
return false;
}
public int hashCode() {
return this.f.hashCode() ^ this.p.hashCode();
}
public String toString() {
String string = String.valueOf(String.valueOf(this.p.toString()));
String string2 = String.valueOf(String.valueOf(this.f.toString()));
return new StringBuilder(2 + string.length() + string2.length()).append(string).append("(").append(string2).append(")").toString();
}
}
private static class InPredicate<T>
implements Predicate<T>,
Serializable {
private final Collection<?> target;
private static final long serialVersionUID = 0L;
private InPredicate(Collection<?> target) {
this.target = Preconditions.checkNotNull(target);
}
@Override
public boolean apply(@Nullable T t) {
try {
return this.target.contains(t);
}
catch (NullPointerException e) {
return false;
}
catch (ClassCastException e) {
return false;
}
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof InPredicate) {
InPredicate that = (InPredicate)obj;
return this.target.equals(that.target);
}
return false;
}
public int hashCode() {
return this.target.hashCode();
}
public String toString() {
String string = String.valueOf(String.valueOf(this.target));
return new StringBuilder(15 + string.length()).append("Predicates.in(").append(string).append(")").toString();
}
}
@GwtIncompatible(value="Class.isAssignableFrom")
private static class AssignableFromPredicate
implements Predicate<Class<?>>,
Serializable {
private final Class<?> clazz;
private static final long serialVersionUID = 0L;
private AssignableFromPredicate(Class<?> clazz) {
this.clazz = Preconditions.checkNotNull(clazz);
}
@Override
public boolean apply(Class<?> input) {
return this.clazz.isAssignableFrom(input);
}
public int hashCode() {
return this.clazz.hashCode();
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof AssignableFromPredicate) {
AssignableFromPredicate that = (AssignableFromPredicate)obj;
return this.clazz == that.clazz;
}
return false;
}
public String toString() {
String string = String.valueOf(String.valueOf(this.clazz.getName()));
return new StringBuilder(27 + string.length()).append("Predicates.assignableFrom(").append(string).append(")").toString();
}
}
@GwtIncompatible(value="Class.isInstance")
private static class InstanceOfPredicate
implements Predicate<Object>,
Serializable {
private final Class<?> clazz;
private static final long serialVersionUID = 0L;
private InstanceOfPredicate(Class<?> clazz) {
this.clazz = Preconditions.checkNotNull(clazz);
}
@Override
public boolean apply(@Nullable Object o) {
return this.clazz.isInstance(o);
}
public int hashCode() {
return this.clazz.hashCode();
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof InstanceOfPredicate) {
InstanceOfPredicate that = (InstanceOfPredicate)obj;
return this.clazz == that.clazz;
}
return false;
}
public String toString() {
String string = String.valueOf(String.valueOf(this.clazz.getName()));
return new StringBuilder(23 + string.length()).append("Predicates.instanceOf(").append(string).append(")").toString();
}
}
private static class IsEqualToPredicate<T>
implements Predicate<T>,
Serializable {
private final T target;
private static final long serialVersionUID = 0L;
private IsEqualToPredicate(T target) {
this.target = target;
}
@Override
public boolean apply(T t) {
return this.target.equals(t);
}
public int hashCode() {
return this.target.hashCode();
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof IsEqualToPredicate) {
IsEqualToPredicate that = (IsEqualToPredicate)obj;
return this.target.equals(that.target);
}
return false;
}
public String toString() {
String string = String.valueOf(String.valueOf(this.target));
return new StringBuilder(20 + string.length()).append("Predicates.equalTo(").append(string).append(")").toString();
}
}
private static class OrPredicate<T>
implements Predicate<T>,
Serializable {
private final List<? extends Predicate<? super T>> components;
private static final long serialVersionUID = 0L;
private OrPredicate(List<? extends Predicate<? super T>> components) {
this.components = components;
}
@Override
public boolean apply(@Nullable T t) {
for (int i = 0; i < this.components.size(); ++i) {
if (!this.components.get(i).apply(t)) continue;
return true;
}
return false;
}
public int hashCode() {
return this.components.hashCode() + 87855567;
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof OrPredicate) {
OrPredicate that = (OrPredicate)obj;
return this.components.equals(that.components);
}
return false;
}
public String toString() {
String string = String.valueOf(String.valueOf(COMMA_JOINER.join(this.components)));
return new StringBuilder(15 + string.length()).append("Predicates.or(").append(string).append(")").toString();
}
}
private static class AndPredicate<T>
implements Predicate<T>,
Serializable {
private final List<? extends Predicate<? super T>> components;
private static final long serialVersionUID = 0L;
private AndPredicate(List<? extends Predicate<? super T>> components) {
this.components = components;
}
@Override
public boolean apply(@Nullable T t) {
for (int i = 0; i < this.components.size(); ++i) {
if (this.components.get(i).apply(t)) continue;
return false;
}
return true;
}
public int hashCode() {
return this.components.hashCode() + 306654252;
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof AndPredicate) {
AndPredicate that = (AndPredicate)obj;
return this.components.equals(that.components);
}
return false;
}
public String toString() {
String string = String.valueOf(String.valueOf(COMMA_JOINER.join(this.components)));
return new StringBuilder(16 + string.length()).append("Predicates.and(").append(string).append(")").toString();
}
}
private static class NotPredicate<T>
implements Predicate<T>,
Serializable {
final Predicate<T> predicate;
private static final long serialVersionUID = 0L;
NotPredicate(Predicate<T> predicate) {
this.predicate = Preconditions.checkNotNull(predicate);
}
@Override
public boolean apply(@Nullable T t) {
return !this.predicate.apply(t);
}
public int hashCode() {
return ~this.predicate.hashCode();
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof NotPredicate) {
NotPredicate that = (NotPredicate)obj;
return this.predicate.equals(that.predicate);
}
return false;
}
public String toString() {
String string = String.valueOf(String.valueOf(this.predicate.toString()));
return new StringBuilder(16 + string.length()).append("Predicates.not(").append(string).append(")").toString();
}
}
static enum ObjectPredicate implements Predicate<Object>
{
ALWAYS_TRUE{
@Override
public boolean apply(@Nullable Object o) {
return true;
}
public String toString() {
return "Predicates.alwaysTrue()";
}
}
,
ALWAYS_FALSE{
@Override
public boolean apply(@Nullable Object o) {
return false;
}
public String toString() {
return "Predicates.alwaysFalse()";
}
}
,
IS_NULL{
@Override
public boolean apply(@Nullable Object o) {
return o == null;
}
public String toString() {
return "Predicates.isNull()";
}
}
,
NOT_NULL{
@Override
public boolean apply(@Nullable Object o) {
return o != null;
}
public String toString() {
return "Predicates.notNull()";
}
};
<T> Predicate<T> withNarrowedType() {
return this;
}
}
}

View file

@ -0,0 +1,87 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Supplier;
import java.util.Collections;
import java.util.Set;
import javax.annotation.Nullable;
@GwtCompatible
final class Present<T>
extends Optional<T> {
private final T reference;
private static final long serialVersionUID = 0L;
Present(T reference) {
this.reference = reference;
}
@Override
public boolean isPresent() {
return true;
}
@Override
public T get() {
return this.reference;
}
@Override
public T or(T defaultValue) {
Preconditions.checkNotNull(defaultValue, "use Optional.orNull() instead of Optional.or(null)");
return this.reference;
}
@Override
public Optional<T> or(Optional<? extends T> secondChoice) {
Preconditions.checkNotNull(secondChoice);
return this;
}
@Override
public T or(Supplier<? extends T> supplier) {
Preconditions.checkNotNull(supplier);
return this.reference;
}
@Override
public T orNull() {
return this.reference;
}
@Override
public Set<T> asSet() {
return Collections.singleton(this.reference);
}
@Override
public <V> Optional<V> transform(Function<? super T, V> function) {
return new Present<V>(Preconditions.checkNotNull(function.apply(this.reference), "the Function passed to Optional.transform() must not return null."));
}
@Override
public boolean equals(@Nullable Object object) {
if (object instanceof Present) {
Present other = (Present)object;
return this.reference.equals(other.reference);
}
return false;
}
@Override
public int hashCode() {
return 1502476572 + this.reference.hashCode();
}
@Override
public String toString() {
String string = String.valueOf(String.valueOf(this.reference));
return new StringBuilder(13 + string.length()).append("Optional.of(").append(string).append(")").toString();
}
}

View file

@ -0,0 +1,100 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.CharMatcher;
import java.util.BitSet;
@GwtIncompatible(value="no precomputation is done in GWT")
final class SmallCharMatcher
extends CharMatcher.FastMatcher {
static final int MAX_SIZE = 1023;
private final char[] table;
private final boolean containsZero;
private final long filter;
private static final int C1 = -862048943;
private static final int C2 = 461845907;
private static final double DESIRED_LOAD_FACTOR = 0.5;
private SmallCharMatcher(char[] table, long filter, boolean containsZero, String description) {
super(description);
this.table = table;
this.filter = filter;
this.containsZero = containsZero;
}
static int smear(int hashCode) {
return 461845907 * Integer.rotateLeft(hashCode * -862048943, 15);
}
private boolean checkFilter(int c) {
return 1L == (1L & this.filter >> c);
}
@VisibleForTesting
static int chooseTableSize(int setSize) {
if (setSize == 1) {
return 2;
}
int tableSize = Integer.highestOneBit(setSize - 1) << 1;
while ((double)tableSize * 0.5 < (double)setSize) {
tableSize <<= 1;
}
return tableSize;
}
static CharMatcher from(BitSet chars, String description) {
long filter = 0L;
int size = chars.cardinality();
boolean containsZero = chars.get(0);
char[] table = new char[SmallCharMatcher.chooseTableSize(size)];
int mask = table.length - 1;
int c = chars.nextSetBit(0);
while (c != -1) {
filter |= 1L << c;
int index = SmallCharMatcher.smear(c) & mask;
while (true) {
if (table[index] == '\u0000') break;
index = index + 1 & mask;
}
table[index] = (char)c;
c = chars.nextSetBit(c + 1);
}
return new SmallCharMatcher(table, filter, containsZero, description);
}
@Override
public boolean matches(char c) {
int startingIndex;
if (c == '\u0000') {
return this.containsZero;
}
if (!this.checkFilter(c)) {
return false;
}
int mask = this.table.length - 1;
int index = startingIndex = SmallCharMatcher.smear(c) & mask;
do {
if (this.table[index] == '\u0000') {
return false;
}
if (this.table[index] != c) continue;
return true;
} while ((index = index + 1 & mask) != startingIndex);
return false;
}
@Override
void setBits(BitSet table) {
if (this.containsZero) {
table.set(0);
}
for (char c : this.table) {
if (c == '\u0000') continue;
table.set(c);
}
}
}

View file

@ -0,0 +1,308 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.AbstractIterator;
import com.google.common.base.CharMatcher;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.CheckReturnValue;
@GwtCompatible(emulated=true)
public final class Splitter {
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
private final Strategy strategy;
private final int limit;
private Splitter(Strategy strategy) {
this(strategy, false, CharMatcher.NONE, Integer.MAX_VALUE);
}
private Splitter(Strategy strategy, boolean omitEmptyStrings, CharMatcher trimmer, int limit) {
this.strategy = strategy;
this.omitEmptyStrings = omitEmptyStrings;
this.trimmer = trimmer;
this.limit = limit;
}
public static Splitter on(char separator) {
return Splitter.on(CharMatcher.is(separator));
}
public static Splitter on(final CharMatcher separatorMatcher) {
Preconditions.checkNotNull(separatorMatcher);
return new Splitter(new Strategy(){
public SplittingIterator iterator(Splitter splitter, CharSequence toSplit) {
return new SplittingIterator(splitter, toSplit){
@Override
int separatorStart(int start) {
return separatorMatcher.indexIn(this.toSplit, start);
}
@Override
int separatorEnd(int separatorPosition) {
return separatorPosition + 1;
}
};
}
});
}
public static Splitter on(final String separator) {
Preconditions.checkArgument(separator.length() != 0, "The separator may not be the empty string.");
return new Splitter(new Strategy(){
public SplittingIterator iterator(Splitter splitter, CharSequence toSplit) {
return new SplittingIterator(splitter, toSplit){
@Override
public int separatorStart(int start) {
int separatorLength = separator.length();
int last = this.toSplit.length() - separatorLength;
block0: for (int p = start; p <= last; ++p) {
for (int i = 0; i < separatorLength; ++i) {
if (this.toSplit.charAt(i + p) != separator.charAt(i)) continue block0;
}
return p;
}
return -1;
}
@Override
public int separatorEnd(int separatorPosition) {
return separatorPosition + separator.length();
}
};
}
});
}
@GwtIncompatible(value="java.util.regex")
public static Splitter on(final Pattern separatorPattern) {
Preconditions.checkNotNull(separatorPattern);
Preconditions.checkArgument(!separatorPattern.matcher("").matches(), "The pattern may not match the empty string: %s", separatorPattern);
return new Splitter(new Strategy(){
public SplittingIterator iterator(Splitter splitter, CharSequence toSplit) {
final Matcher matcher = separatorPattern.matcher(toSplit);
return new SplittingIterator(splitter, toSplit){
@Override
public int separatorStart(int start) {
return matcher.find(start) ? matcher.start() : -1;
}
@Override
public int separatorEnd(int separatorPosition) {
return matcher.end();
}
};
}
});
}
@GwtIncompatible(value="java.util.regex")
public static Splitter onPattern(String separatorPattern) {
return Splitter.on(Pattern.compile(separatorPattern));
}
public static Splitter fixedLength(final int length) {
Preconditions.checkArgument(length > 0, "The length may not be less than 1");
return new Splitter(new Strategy(){
public SplittingIterator iterator(Splitter splitter, CharSequence toSplit) {
return new SplittingIterator(splitter, toSplit){
@Override
public int separatorStart(int start) {
int nextChunkStart = start + length;
return nextChunkStart < this.toSplit.length() ? nextChunkStart : -1;
}
@Override
public int separatorEnd(int separatorPosition) {
return separatorPosition;
}
};
}
});
}
@CheckReturnValue
public Splitter omitEmptyStrings() {
return new Splitter(this.strategy, true, this.trimmer, this.limit);
}
@CheckReturnValue
public Splitter limit(int limit) {
Preconditions.checkArgument(limit > 0, "must be greater than zero: %s", limit);
return new Splitter(this.strategy, this.omitEmptyStrings, this.trimmer, limit);
}
@CheckReturnValue
public Splitter trimResults() {
return this.trimResults(CharMatcher.WHITESPACE);
}
@CheckReturnValue
public Splitter trimResults(CharMatcher trimmer) {
Preconditions.checkNotNull(trimmer);
return new Splitter(this.strategy, this.omitEmptyStrings, trimmer, this.limit);
}
public Iterable<String> split(final CharSequence sequence) {
Preconditions.checkNotNull(sequence);
return new Iterable<String>(){
@Override
public Iterator<String> iterator() {
return Splitter.this.splittingIterator(sequence);
}
public String toString() {
return Joiner.on(", ").appendTo(new StringBuilder().append('['), (Iterable<?>)this).append(']').toString();
}
};
}
private Iterator<String> splittingIterator(CharSequence sequence) {
return this.strategy.iterator(this, sequence);
}
@Beta
public List<String> splitToList(CharSequence sequence) {
Preconditions.checkNotNull(sequence);
Iterator<String> iterator = this.splittingIterator(sequence);
ArrayList<String> result = new ArrayList<String>();
while (iterator.hasNext()) {
result.add(iterator.next());
}
return Collections.unmodifiableList(result);
}
@CheckReturnValue
@Beta
public MapSplitter withKeyValueSeparator(String separator) {
return this.withKeyValueSeparator(Splitter.on(separator));
}
@CheckReturnValue
@Beta
public MapSplitter withKeyValueSeparator(char separator) {
return this.withKeyValueSeparator(Splitter.on(separator));
}
@CheckReturnValue
@Beta
public MapSplitter withKeyValueSeparator(Splitter keyValueSplitter) {
return new MapSplitter(this, keyValueSplitter);
}
private static abstract class SplittingIterator
extends AbstractIterator<String> {
final CharSequence toSplit;
final CharMatcher trimmer;
final boolean omitEmptyStrings;
int offset = 0;
int limit;
abstract int separatorStart(int var1);
abstract int separatorEnd(int var1);
protected SplittingIterator(Splitter splitter, CharSequence toSplit) {
this.trimmer = splitter.trimmer;
this.omitEmptyStrings = splitter.omitEmptyStrings;
this.limit = splitter.limit;
this.toSplit = toSplit;
}
@Override
protected String computeNext() {
int nextStart = this.offset;
while (this.offset != -1) {
int end;
int start = nextStart;
int separatorPosition = this.separatorStart(this.offset);
if (separatorPosition == -1) {
end = this.toSplit.length();
this.offset = -1;
} else {
end = separatorPosition;
this.offset = this.separatorEnd(separatorPosition);
}
if (this.offset == nextStart) {
++this.offset;
if (this.offset < this.toSplit.length()) continue;
this.offset = -1;
continue;
}
while (start < end && this.trimmer.matches(this.toSplit.charAt(start))) {
++start;
}
while (end > start && this.trimmer.matches(this.toSplit.charAt(end - 1))) {
--end;
}
if (this.omitEmptyStrings && start == end) {
nextStart = this.offset;
continue;
}
if (this.limit == 1) {
this.offset = -1;
for (end = this.toSplit.length(); end > start && this.trimmer.matches(this.toSplit.charAt(end - 1)); --end) {
}
} else {
--this.limit;
}
return this.toSplit.subSequence(start, end).toString();
}
return (String)this.endOfData();
}
}
private static interface Strategy {
public Iterator<String> iterator(Splitter var1, CharSequence var2);
}
@Beta
public static final class MapSplitter {
private static final String INVALID_ENTRY_MESSAGE = "Chunk [%s] is not a valid entry";
private final Splitter outerSplitter;
private final Splitter entrySplitter;
private MapSplitter(Splitter outerSplitter, Splitter entrySplitter) {
this.outerSplitter = outerSplitter;
this.entrySplitter = Preconditions.checkNotNull(entrySplitter);
}
public Map<String, String> split(CharSequence sequence) {
LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
for (String entry : this.outerSplitter.split(sequence)) {
Iterator entryFields = this.entrySplitter.splittingIterator(entry);
Preconditions.checkArgument(entryFields.hasNext(), INVALID_ENTRY_MESSAGE, entry);
String key = (String)entryFields.next();
Preconditions.checkArgument(!map.containsKey(key), "Duplicate key [%s] found.", key);
Preconditions.checkArgument(entryFields.hasNext(), INVALID_ENTRY_MESSAGE, entry);
String value = (String)entryFields.next();
map.put(key, value);
Preconditions.checkArgument(!entryFields.hasNext(), INVALID_ENTRY_MESSAGE, entry);
}
return Collections.unmodifiableMap(map);
}
}
}

View file

@ -0,0 +1,62 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import javax.annotation.Nullable;
@Beta
@GwtIncompatible(value="java.lang.System#getProperty")
public enum StandardSystemProperty {
JAVA_VERSION("java.version"),
JAVA_VENDOR("java.vendor"),
JAVA_VENDOR_URL("java.vendor.url"),
JAVA_HOME("java.home"),
JAVA_VM_SPECIFICATION_VERSION("java.vm.specification.version"),
JAVA_VM_SPECIFICATION_VENDOR("java.vm.specification.vendor"),
JAVA_VM_SPECIFICATION_NAME("java.vm.specification.name"),
JAVA_VM_VERSION("java.vm.version"),
JAVA_VM_VENDOR("java.vm.vendor"),
JAVA_VM_NAME("java.vm.name"),
JAVA_SPECIFICATION_VERSION("java.specification.version"),
JAVA_SPECIFICATION_VENDOR("java.specification.vendor"),
JAVA_SPECIFICATION_NAME("java.specification.name"),
JAVA_CLASS_VERSION("java.class.version"),
JAVA_CLASS_PATH("java.class.path"),
JAVA_LIBRARY_PATH("java.library.path"),
JAVA_IO_TMPDIR("java.io.tmpdir"),
JAVA_COMPILER("java.compiler"),
JAVA_EXT_DIRS("java.ext.dirs"),
OS_NAME("os.name"),
OS_ARCH("os.arch"),
OS_VERSION("os.version"),
FILE_SEPARATOR("file.separator"),
PATH_SEPARATOR("path.separator"),
LINE_SEPARATOR("line.separator"),
USER_NAME("user.name"),
USER_HOME("user.home"),
USER_DIR("user.dir");
private final String key;
private StandardSystemProperty(String key) {
this.key = key;
}
public String key() {
return this.key;
}
@Nullable
public String value() {
return System.getProperty(this.key);
}
public String toString() {
String string = String.valueOf(String.valueOf(this.key()));
String string2 = String.valueOf(String.valueOf(this.value()));
return new StringBuilder(1 + string.length() + string2.length()).append(string).append("=").append(string2).toString();
}
}

View file

@ -0,0 +1,136 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Preconditions;
import com.google.common.base.Ticker;
import java.util.concurrent.TimeUnit;
@Beta
@GwtCompatible(emulated=true)
public final class Stopwatch {
private final Ticker ticker;
private boolean isRunning;
private long elapsedNanos;
private long startTick;
public static Stopwatch createUnstarted() {
return new Stopwatch();
}
public static Stopwatch createUnstarted(Ticker ticker) {
return new Stopwatch(ticker);
}
public static Stopwatch createStarted() {
return new Stopwatch().start();
}
public static Stopwatch createStarted(Ticker ticker) {
return new Stopwatch(ticker).start();
}
@Deprecated
Stopwatch() {
this(Ticker.systemTicker());
}
@Deprecated
Stopwatch(Ticker ticker) {
this.ticker = Preconditions.checkNotNull(ticker, "ticker");
}
public boolean isRunning() {
return this.isRunning;
}
public Stopwatch start() {
Preconditions.checkState(!this.isRunning, "This stopwatch is already running.");
this.isRunning = true;
this.startTick = this.ticker.read();
return this;
}
public Stopwatch stop() {
long tick = this.ticker.read();
Preconditions.checkState(this.isRunning, "This stopwatch is already stopped.");
this.isRunning = false;
this.elapsedNanos += tick - this.startTick;
return this;
}
public Stopwatch reset() {
this.elapsedNanos = 0L;
this.isRunning = false;
return this;
}
private long elapsedNanos() {
return this.isRunning ? this.ticker.read() - this.startTick + this.elapsedNanos : this.elapsedNanos;
}
public long elapsed(TimeUnit desiredUnit) {
return desiredUnit.convert(this.elapsedNanos(), TimeUnit.NANOSECONDS);
}
@GwtIncompatible(value="String.format()")
public String toString() {
long nanos = this.elapsedNanos();
TimeUnit unit = Stopwatch.chooseUnit(nanos);
double value = (double)nanos / (double)TimeUnit.NANOSECONDS.convert(1L, unit);
return String.format("%.4g %s", value, Stopwatch.abbreviate(unit));
}
private static TimeUnit chooseUnit(long nanos) {
if (TimeUnit.DAYS.convert(nanos, TimeUnit.NANOSECONDS) > 0L) {
return TimeUnit.DAYS;
}
if (TimeUnit.HOURS.convert(nanos, TimeUnit.NANOSECONDS) > 0L) {
return TimeUnit.HOURS;
}
if (TimeUnit.MINUTES.convert(nanos, TimeUnit.NANOSECONDS) > 0L) {
return TimeUnit.MINUTES;
}
if (TimeUnit.SECONDS.convert(nanos, TimeUnit.NANOSECONDS) > 0L) {
return TimeUnit.SECONDS;
}
if (TimeUnit.MILLISECONDS.convert(nanos, TimeUnit.NANOSECONDS) > 0L) {
return TimeUnit.MILLISECONDS;
}
if (TimeUnit.MICROSECONDS.convert(nanos, TimeUnit.NANOSECONDS) > 0L) {
return TimeUnit.MICROSECONDS;
}
return TimeUnit.NANOSECONDS;
}
private static String abbreviate(TimeUnit unit) {
switch (unit) {
case NANOSECONDS: {
return "ns";
}
case MICROSECONDS: {
return "\u03bcs";
}
case MILLISECONDS: {
return "ms";
}
case SECONDS: {
return "s";
}
case MINUTES: {
return "min";
}
case HOURS: {
return "h";
}
case DAYS: {
return "d";
}
}
throw new AssertionError();
}
}

View file

@ -0,0 +1,108 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import javax.annotation.Nullable;
@GwtCompatible
public final class Strings {
private Strings() {
}
public static String nullToEmpty(@Nullable String string) {
return string == null ? "" : string;
}
@Nullable
public static String emptyToNull(@Nullable String string) {
return Strings.isNullOrEmpty(string) ? null : string;
}
public static boolean isNullOrEmpty(@Nullable String string) {
return string == null || string.length() == 0;
}
public static String padStart(String string, int minLength, char padChar) {
Preconditions.checkNotNull(string);
if (string.length() >= minLength) {
return string;
}
StringBuilder sb = new StringBuilder(minLength);
for (int i = string.length(); i < minLength; ++i) {
sb.append(padChar);
}
sb.append(string);
return sb.toString();
}
public static String padEnd(String string, int minLength, char padChar) {
Preconditions.checkNotNull(string);
if (string.length() >= minLength) {
return string;
}
StringBuilder sb = new StringBuilder(minLength);
sb.append(string);
for (int i = string.length(); i < minLength; ++i) {
sb.append(padChar);
}
return sb.toString();
}
public static String repeat(String string, int count) {
int n;
Preconditions.checkNotNull(string);
if (count <= 1) {
Preconditions.checkArgument(count >= 0, "invalid count: %s", count);
return count == 0 ? "" : string;
}
int len = string.length();
long longSize = (long)len * (long)count;
int size = (int)longSize;
if ((long)size != longSize) {
long l = longSize;
throw new ArrayIndexOutOfBoundsException(new StringBuilder(51).append("Required array size too large: ").append(l).toString());
}
char[] array = new char[size];
string.getChars(0, len, array, 0);
for (n = len; n < size - n; n <<= 1) {
System.arraycopy(array, 0, array, n, n);
}
System.arraycopy(array, 0, array, n, size - n);
return new String(array);
}
public static String commonPrefix(CharSequence a, CharSequence b) {
int p;
Preconditions.checkNotNull(a);
Preconditions.checkNotNull(b);
int maxPrefixLength = Math.min(a.length(), b.length());
for (p = 0; p < maxPrefixLength && a.charAt(p) == b.charAt(p); ++p) {
}
if (Strings.validSurrogatePairAt(a, p - 1) || Strings.validSurrogatePairAt(b, p - 1)) {
--p;
}
return a.subSequence(0, p).toString();
}
public static String commonSuffix(CharSequence a, CharSequence b) {
int s;
Preconditions.checkNotNull(a);
Preconditions.checkNotNull(b);
int maxSuffixLength = Math.min(a.length(), b.length());
for (s = 0; s < maxSuffixLength && a.charAt(a.length() - s - 1) == b.charAt(b.length() - s - 1); ++s) {
}
if (Strings.validSurrogatePairAt(a, a.length() - s - 1) || Strings.validSurrogatePairAt(b, b.length() - s - 1)) {
--s;
}
return a.subSequence(a.length() - s, a.length()).toString();
}
@VisibleForTesting
static boolean validSurrogatePairAt(CharSequence string, int index) {
return index >= 0 && index <= string.length() - 2 && Character.isHighSurrogate(string.charAt(index)) && Character.isLowSurrogate(string.charAt(index + 1));
}
}

View file

@ -0,0 +1,11 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.GwtCompatible;
@GwtCompatible
public interface Supplier<T> {
public T get();
}

View file

@ -0,0 +1,248 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Platform;
import com.google.common.base.Preconditions;
import com.google.common.base.Supplier;
import java.io.Serializable;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
@GwtCompatible
public final class Suppliers {
private Suppliers() {
}
public static <F, T> Supplier<T> compose(Function<? super F, T> function, Supplier<F> supplier) {
Preconditions.checkNotNull(function);
Preconditions.checkNotNull(supplier);
return new SupplierComposition<F, T>(function, supplier);
}
public static <T> Supplier<T> memoize(Supplier<T> delegate) {
return delegate instanceof MemoizingSupplier ? delegate : new MemoizingSupplier(Preconditions.checkNotNull(delegate));
}
public static <T> Supplier<T> memoizeWithExpiration(Supplier<T> delegate, long duration, TimeUnit unit) {
return new ExpiringMemoizingSupplier<T>(delegate, duration, unit);
}
public static <T> Supplier<T> ofInstance(@Nullable T instance) {
return new SupplierOfInstance<T>(instance);
}
public static <T> Supplier<T> synchronizedSupplier(Supplier<T> delegate) {
return new ThreadSafeSupplier<T>(Preconditions.checkNotNull(delegate));
}
@Beta
public static <T> Function<Supplier<T>, T> supplierFunction() {
SupplierFunctionImpl sf = SupplierFunctionImpl.INSTANCE;
return sf;
}
private static enum SupplierFunctionImpl implements SupplierFunction<Object>
{
INSTANCE;
@Override
public Object apply(Supplier<Object> input) {
return input.get();
}
public String toString() {
return "Suppliers.supplierFunction()";
}
}
private static interface SupplierFunction<T>
extends Function<Supplier<T>, T> {
}
private static class ThreadSafeSupplier<T>
implements Supplier<T>,
Serializable {
final Supplier<T> delegate;
private static final long serialVersionUID = 0L;
ThreadSafeSupplier(Supplier<T> delegate) {
this.delegate = delegate;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
@Override
public T get() {
Supplier<T> supplier = this.delegate;
synchronized (supplier) {
return this.delegate.get();
}
}
public String toString() {
String string = String.valueOf(String.valueOf(this.delegate));
return new StringBuilder(32 + string.length()).append("Suppliers.synchronizedSupplier(").append(string).append(")").toString();
}
}
private static class SupplierOfInstance<T>
implements Supplier<T>,
Serializable {
final T instance;
private static final long serialVersionUID = 0L;
SupplierOfInstance(@Nullable T instance) {
this.instance = instance;
}
@Override
public T get() {
return this.instance;
}
public boolean equals(@Nullable Object obj) {
if (obj instanceof SupplierOfInstance) {
SupplierOfInstance that = (SupplierOfInstance)obj;
return Objects.equal(this.instance, that.instance);
}
return false;
}
public int hashCode() {
return Objects.hashCode(this.instance);
}
public String toString() {
String string = String.valueOf(String.valueOf(this.instance));
return new StringBuilder(22 + string.length()).append("Suppliers.ofInstance(").append(string).append(")").toString();
}
}
@VisibleForTesting
static class ExpiringMemoizingSupplier<T>
implements Supplier<T>,
Serializable {
final Supplier<T> delegate;
final long durationNanos;
volatile transient T value;
volatile transient long expirationNanos;
private static final long serialVersionUID = 0L;
ExpiringMemoizingSupplier(Supplier<T> delegate, long duration, TimeUnit unit) {
this.delegate = Preconditions.checkNotNull(delegate);
this.durationNanos = unit.toNanos(duration);
Preconditions.checkArgument(duration > 0L);
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
@Override
public T get() {
long nanos = this.expirationNanos;
long now = Platform.systemNanoTime();
if (nanos == 0L || now - nanos >= 0L) {
ExpiringMemoizingSupplier expiringMemoizingSupplier = this;
synchronized (expiringMemoizingSupplier) {
if (nanos == this.expirationNanos) {
T t = this.delegate.get();
this.value = t;
nanos = now + this.durationNanos;
this.expirationNanos = nanos == 0L ? 1L : nanos;
return t;
}
}
}
return this.value;
}
public String toString() {
String string = String.valueOf(String.valueOf(this.delegate));
long l = this.durationNanos;
return new StringBuilder(62 + string.length()).append("Suppliers.memoizeWithExpiration(").append(string).append(", ").append(l).append(", NANOS)").toString();
}
}
@VisibleForTesting
static class MemoizingSupplier<T>
implements Supplier<T>,
Serializable {
final Supplier<T> delegate;
volatile transient boolean initialized;
transient T value;
private static final long serialVersionUID = 0L;
MemoizingSupplier(Supplier<T> delegate) {
this.delegate = delegate;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
@Override
public T get() {
if (!this.initialized) {
MemoizingSupplier memoizingSupplier = this;
synchronized (memoizingSupplier) {
if (!this.initialized) {
T t = this.delegate.get();
this.value = t;
this.initialized = true;
return t;
}
}
}
return this.value;
}
public String toString() {
String string = String.valueOf(String.valueOf(this.delegate));
return new StringBuilder(19 + string.length()).append("Suppliers.memoize(").append(string).append(")").toString();
}
}
private static class SupplierComposition<F, T>
implements Supplier<T>,
Serializable {
final Function<? super F, T> function;
final Supplier<F> supplier;
private static final long serialVersionUID = 0L;
SupplierComposition(Function<? super F, T> function, Supplier<F> supplier) {
this.function = function;
this.supplier = supplier;
}
@Override
public T get() {
return this.function.apply(this.supplier.get());
}
public boolean equals(@Nullable Object obj) {
if (obj instanceof SupplierComposition) {
SupplierComposition that = (SupplierComposition)obj;
return this.function.equals(that.function) && this.supplier.equals(that.supplier);
}
return false;
}
public int hashCode() {
return Objects.hashCode(this.function, this.supplier);
}
public String toString() {
String string = String.valueOf(String.valueOf(this.function));
String string2 = String.valueOf(String.valueOf(this.supplier));
return new StringBuilder(21 + string.length() + string2.length()).append("Suppliers.compose(").append(string).append(", ").append(string2).append(")").toString();
}
}
}

View file

@ -0,0 +1,70 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
public final class Throwables {
private Throwables() {
}
public static <X extends Throwable> void propagateIfInstanceOf(@Nullable Throwable throwable, Class<X> declaredType) throws X {
if (throwable != null && declaredType.isInstance(throwable)) {
throw (Throwable)declaredType.cast(throwable);
}
}
public static void propagateIfPossible(@Nullable Throwable throwable) {
Throwables.propagateIfInstanceOf(throwable, Error.class);
Throwables.propagateIfInstanceOf(throwable, RuntimeException.class);
}
public static <X extends Throwable> void propagateIfPossible(@Nullable Throwable throwable, Class<X> declaredType) throws X {
Throwables.propagateIfInstanceOf(throwable, declaredType);
Throwables.propagateIfPossible(throwable);
}
public static <X1 extends Throwable, X2 extends Throwable> void propagateIfPossible(@Nullable Throwable throwable, Class<X1> declaredType1, Class<X2> declaredType2) throws X1, X2 {
Preconditions.checkNotNull(declaredType2);
Throwables.propagateIfInstanceOf(throwable, declaredType1);
Throwables.propagateIfPossible(throwable, declaredType2);
}
public static RuntimeException propagate(Throwable throwable) {
Throwables.propagateIfPossible(Preconditions.checkNotNull(throwable));
throw new RuntimeException(throwable);
}
public static Throwable getRootCause(Throwable throwable) {
Throwable cause;
while ((cause = throwable.getCause()) != null) {
throwable = cause;
}
return throwable;
}
@Beta
public static List<Throwable> getCausalChain(Throwable throwable) {
Preconditions.checkNotNull(throwable);
ArrayList<Throwable> causes = new ArrayList<Throwable>(4);
while (throwable != null) {
causes.add(throwable);
throwable = throwable.getCause();
}
return Collections.unmodifiableList(causes);
}
public static String getStackTraceAsString(Throwable throwable) {
StringWriter stringWriter = new StringWriter();
throwable.printStackTrace(new PrintWriter(stringWriter));
return stringWriter.toString();
}
}

View file

@ -0,0 +1,29 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Platform;
@Beta
@GwtCompatible
public abstract class Ticker {
private static final Ticker SYSTEM_TICKER = new Ticker(){
@Override
public long read() {
return Platform.systemNanoTime();
}
};
protected Ticker() {
}
public abstract long read();
public static Ticker systemTicker() {
return SYSTEM_TICKER;
}
}

View file

@ -0,0 +1,104 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Preconditions;
@Beta
@GwtCompatible
public final class Utf8 {
public static int encodedLength(CharSequence sequence) {
int i;
int utf16Length;
int utf8Length = utf16Length = sequence.length();
for (i = 0; i < utf16Length && sequence.charAt(i) < '\u0080'; ++i) {
}
while (i < utf16Length) {
char c = sequence.charAt(i);
if (c < '\u0800') {
utf8Length += 127 - c >>> 31;
} else {
utf8Length += Utf8.encodedLengthGeneral(sequence, i);
break;
}
++i;
}
if (utf8Length < utf16Length) {
long l = (long)utf8Length + 0x100000000L;
throw new IllegalArgumentException(new StringBuilder(54).append("UTF-8 length does not fit in int: ").append(l).toString());
}
return utf8Length;
}
private static int encodedLengthGeneral(CharSequence sequence, int start) {
int utf16Length = sequence.length();
int utf8Length = 0;
for (int i = start; i < utf16Length; ++i) {
char c = sequence.charAt(i);
if (c < '\u0800') {
utf8Length += 127 - c >>> 31;
continue;
}
utf8Length += 2;
if ('\ud800' > c || c > '\udfff') continue;
int cp = Character.codePointAt(sequence, i);
if (cp < 65536) {
int n = i;
throw new IllegalArgumentException(new StringBuilder(39).append("Unpaired surrogate at index ").append(n).toString());
}
++i;
}
return utf8Length;
}
public static boolean isWellFormed(byte[] bytes) {
return Utf8.isWellFormed(bytes, 0, bytes.length);
}
public static boolean isWellFormed(byte[] bytes, int off, int len) {
int end = off + len;
Preconditions.checkPositionIndexes(off, end, bytes.length);
for (int i = off; i < end; ++i) {
if (bytes[i] >= 0) continue;
return Utf8.isWellFormedSlowPath(bytes, i, end);
}
return true;
}
private static boolean isWellFormedSlowPath(byte[] bytes, int off, int end) {
int index = off;
while (true) {
byte byte2;
byte byte1;
if (index >= end) {
return true;
}
if ((byte1 = bytes[index++]) >= 0) continue;
if (byte1 < -32) {
if (index == end) {
return false;
}
if (byte1 >= -62 && bytes[index++] <= -65) continue;
return false;
}
if (byte1 < -16) {
if (index + 1 >= end) {
return false;
}
if (!((byte2 = bytes[index++]) > -65 || byte1 == -32 && byte2 < -96 || byte1 == -19 && -96 <= byte2) && bytes[index++] <= -65) continue;
return false;
}
if (index + 2 >= end) {
return false;
}
if ((byte2 = bytes[index++]) > -65 || (byte1 << 28) + (byte2 - -112) >> 30 != 0 || bytes[index++] > -65 || bytes[index++] > -65) break;
}
return false;
}
private Utf8() {
}
}

View file

@ -0,0 +1,38 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Preconditions;
import com.google.common.base.VerifyException;
import javax.annotation.Nullable;
@Beta
@GwtCompatible
public final class Verify {
public static void verify(boolean expression) {
if (!expression) {
throw new VerifyException();
}
}
public static void verify(boolean expression, @Nullable String errorMessageTemplate, Object ... errorMessageArgs) {
if (!expression) {
throw new VerifyException(Preconditions.format(errorMessageTemplate, errorMessageArgs));
}
}
public static <T> T verifyNotNull(@Nullable T reference) {
return Verify.verifyNotNull(reference, "expected a non-null reference", new Object[0]);
}
public static <T> T verifyNotNull(@Nullable T reference, @Nullable String errorMessageTemplate, Object ... errorMessageArgs) {
Verify.verify(reference != null, errorMessageTemplate, errorMessageArgs);
return reference;
}
private Verify() {
}
}

View file

@ -0,0 +1,20 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import javax.annotation.Nullable;
@Beta
@GwtCompatible
public class VerifyException
extends RuntimeException {
public VerifyException() {
}
public VerifyException(@Nullable String message) {
super(message);
}
}

View file

@ -0,0 +1,107 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.base.internal;
import java.lang.ref.PhantomReference;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Finalizer
implements Runnable {
private static final Logger logger = Logger.getLogger(Finalizer.class.getName());
private static final String FINALIZABLE_REFERENCE = "com.google.common.base.FinalizableReference";
private final WeakReference<Class<?>> finalizableReferenceClassReference;
private final PhantomReference<Object> frqReference;
private final ReferenceQueue<Object> queue;
private static final Field inheritableThreadLocals = Finalizer.getInheritableThreadLocalsField();
public static void startFinalizer(Class<?> finalizableReferenceClass, ReferenceQueue<Object> queue, PhantomReference<Object> frqReference) {
if (!finalizableReferenceClass.getName().equals(FINALIZABLE_REFERENCE)) {
throw new IllegalArgumentException("Expected com.google.common.base.FinalizableReference.");
}
Finalizer finalizer = new Finalizer(finalizableReferenceClass, queue, frqReference);
Thread thread = new Thread(finalizer);
thread.setName(Finalizer.class.getName());
thread.setDaemon(true);
try {
if (inheritableThreadLocals != null) {
inheritableThreadLocals.set(thread, null);
}
}
catch (Throwable t) {
logger.log(Level.INFO, "Failed to clear thread local values inherited by reference finalizer thread.", t);
}
thread.start();
}
private Finalizer(Class<?> finalizableReferenceClass, ReferenceQueue<Object> queue, PhantomReference<Object> frqReference) {
this.queue = queue;
this.finalizableReferenceClassReference = new WeakReference(finalizableReferenceClass);
this.frqReference = frqReference;
}
@Override
public void run() {
while (true) {
try {
while (this.cleanUp(this.queue.remove())) {
}
}
catch (InterruptedException interruptedException) {
continue;
}
break;
}
}
private boolean cleanUp(Reference<?> reference) {
Method finalizeReferentMethod = this.getFinalizeReferentMethod();
if (finalizeReferentMethod == null) {
return false;
}
do {
reference.clear();
if (reference == this.frqReference) {
return false;
}
try {
finalizeReferentMethod.invoke(reference, new Object[0]);
}
catch (Throwable t) {
logger.log(Level.SEVERE, "Error cleaning up after reference.", t);
}
} while ((reference = this.queue.poll()) != null);
return true;
}
private Method getFinalizeReferentMethod() {
Class finalizableReferenceClass = (Class)this.finalizableReferenceClassReference.get();
if (finalizableReferenceClass == null) {
return null;
}
try {
return finalizableReferenceClass.getMethod("finalizeReferent", new Class[0]);
}
catch (NoSuchMethodException e) {
throw new AssertionError((Object)e);
}
}
public static Field getInheritableThreadLocalsField() {
try {
Field inheritableThreadLocals = Thread.class.getDeclaredField("inheritableThreadLocals");
inheritableThreadLocals.setAccessible(true);
return inheritableThreadLocals;
}
catch (Throwable t) {
logger.log(Level.INFO, "Couldn't access Thread.inheritableThreadLocals. Reference finalizer threads will inherit thread local values.");
return null;
}
}
}

View file

@ -0,0 +1,8 @@
/*
* Decompiled with CFR 0.152.
*/
@ParametersAreNonnullByDefault
package com.google.common.base;
import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -0,0 +1,160 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.cache;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheStats;
import com.google.common.cache.LongAddable;
import com.google.common.cache.LongAddables;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
@Beta
@GwtCompatible
public abstract class AbstractCache<K, V>
implements Cache<K, V> {
protected AbstractCache() {
}
@Override
public V get(K key, Callable<? extends V> valueLoader) throws ExecutionException {
throw new UnsupportedOperationException();
}
@Override
public ImmutableMap<K, V> getAllPresent(Iterable<?> keys) {
LinkedHashMap result = Maps.newLinkedHashMap();
for (Object key : keys) {
if (result.containsKey(key)) continue;
Object castKey = key;
Object value = this.getIfPresent(key);
if (value == null) continue;
result.put(castKey, value);
}
return ImmutableMap.copyOf(result);
}
@Override
public void put(K key, V value) {
throw new UnsupportedOperationException();
}
@Override
public void putAll(Map<? extends K, ? extends V> m) {
for (Map.Entry<K, V> entry : m.entrySet()) {
this.put(entry.getKey(), entry.getValue());
}
}
@Override
public void cleanUp() {
}
@Override
public long size() {
throw new UnsupportedOperationException();
}
@Override
public void invalidate(Object key) {
throw new UnsupportedOperationException();
}
@Override
public void invalidateAll(Iterable<?> keys) {
for (Object key : keys) {
this.invalidate(key);
}
}
@Override
public void invalidateAll() {
throw new UnsupportedOperationException();
}
@Override
public CacheStats stats() {
throw new UnsupportedOperationException();
}
@Override
public ConcurrentMap<K, V> asMap() {
throw new UnsupportedOperationException();
}
@Beta
public static final class SimpleStatsCounter
implements StatsCounter {
private final LongAddable hitCount = LongAddables.create();
private final LongAddable missCount = LongAddables.create();
private final LongAddable loadSuccessCount = LongAddables.create();
private final LongAddable loadExceptionCount = LongAddables.create();
private final LongAddable totalLoadTime = LongAddables.create();
private final LongAddable evictionCount = LongAddables.create();
@Override
public void recordHits(int count) {
this.hitCount.add(count);
}
@Override
public void recordMisses(int count) {
this.missCount.add(count);
}
@Override
public void recordLoadSuccess(long loadTime) {
this.loadSuccessCount.increment();
this.totalLoadTime.add(loadTime);
}
@Override
public void recordLoadException(long loadTime) {
this.loadExceptionCount.increment();
this.totalLoadTime.add(loadTime);
}
@Override
public void recordEviction() {
this.evictionCount.increment();
}
@Override
public CacheStats snapshot() {
return new CacheStats(this.hitCount.sum(), this.missCount.sum(), this.loadSuccessCount.sum(), this.loadExceptionCount.sum(), this.totalLoadTime.sum(), this.evictionCount.sum());
}
public void incrementBy(StatsCounter other) {
CacheStats otherStats = other.snapshot();
this.hitCount.add(otherStats.hitCount());
this.missCount.add(otherStats.missCount());
this.loadSuccessCount.add(otherStats.loadSuccessCount());
this.loadExceptionCount.add(otherStats.loadExceptionCount());
this.totalLoadTime.add(otherStats.totalLoadTime());
this.evictionCount.add(otherStats.evictionCount());
}
}
@Beta
public static interface StatsCounter {
public void recordHits(int var1);
public void recordMisses(int var1);
public void recordLoadSuccess(long var1);
public void recordLoadException(long var1);
public void recordEviction();
public CacheStats snapshot();
}
}

View file

@ -0,0 +1,51 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.cache;
import com.google.common.annotations.Beta;
import com.google.common.cache.AbstractCache;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.util.concurrent.UncheckedExecutionException;
import java.util.LinkedHashMap;
import java.util.concurrent.ExecutionException;
@Beta
public abstract class AbstractLoadingCache<K, V>
extends AbstractCache<K, V>
implements LoadingCache<K, V> {
protected AbstractLoadingCache() {
}
@Override
public V getUnchecked(K key) {
try {
return this.get(key);
}
catch (ExecutionException e) {
throw new UncheckedExecutionException(e.getCause());
}
}
@Override
public ImmutableMap<K, V> getAll(Iterable<? extends K> keys) throws ExecutionException {
LinkedHashMap result = Maps.newLinkedHashMap();
for (K key : keys) {
if (result.containsKey(key)) continue;
result.put(key, this.get(key));
}
return ImmutableMap.copyOf(result);
}
@Override
public final V apply(K key) {
return this.getUnchecked(key);
}
@Override
public void refresh(K key) {
throw new UnsupportedOperationException();
}
}

43
src/com/google/common/cache/Cache.java vendored Normal file
View file

@ -0,0 +1,43 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.cache;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.cache.CacheStats;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
import javax.annotation.Nullable;
@Beta
@GwtCompatible
public interface Cache<K, V> {
@Nullable
public V getIfPresent(Object var1);
public V get(K var1, Callable<? extends V> var2) throws ExecutionException;
public ImmutableMap<K, V> getAllPresent(Iterable<?> var1);
public void put(K var1, V var2);
public void putAll(Map<? extends K, ? extends V> var1);
public void invalidate(Object var1);
public void invalidateAll(Iterable<?> var1);
public void invalidateAll();
public long size();
public CacheStats stats();
public ConcurrentMap<K, V> asMap();
public void cleanUp();
}

View file

@ -0,0 +1,402 @@
/*
* Decompiled with CFR 0.152.
*/
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.Ascii;
import com.google.common.base.Equivalence;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.base.Ticker;
import com.google.common.cache.AbstractCache;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilderSpec;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.CacheStats;
import com.google.common.cache.LoadingCache;
import com.google.common.cache.LocalCache;
import com.google.common.cache.RemovalListener;
import com.google.common.cache.RemovalNotification;
import com.google.common.cache.Weigher;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckReturnValue;
@GwtCompatible(emulated=true)
public final class CacheBuilder<K, V> {
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private static final int DEFAULT_CONCURRENCY_LEVEL = 4;
private static final int DEFAULT_EXPIRATION_NANOS = 0;
private static final int DEFAULT_REFRESH_NANOS = 0;
static final Supplier<? extends AbstractCache.StatsCounter> NULL_STATS_COUNTER = Suppliers.ofInstance(new AbstractCache.StatsCounter(){
@Override
public void recordHits(int count) {
}
@Override
public void recordMisses(int count) {
}
@Override
public void recordLoadSuccess(long loadTime) {
}
@Override
public void recordLoadException(long loadTime) {
}
@Override
public void recordEviction() {
}
@Override
public CacheStats snapshot() {
return EMPTY_STATS;
}
});
static final CacheStats EMPTY_STATS = new CacheStats(0L, 0L, 0L, 0L, 0L, 0L);
static final Supplier<AbstractCache.StatsCounter> CACHE_STATS_COUNTER = new Supplier<AbstractCache.StatsCounter>(){
@Override
public AbstractCache.StatsCounter get() {
return new AbstractCache.SimpleStatsCounter();
}
};
static final Ticker NULL_TICKER = new Ticker(){
@Override
public long read() {
return 0L;
}
};
private static final Logger logger = Logger.getLogger(CacheBuilder.class.getName());
static final int UNSET_INT = -1;
boolean strictParsing = true;
int initialCapacity = -1;
int concurrencyLevel = -1;
long maximumSize = -1L;
long maximumWeight = -1L;
Weigher<? super K, ? super V> weigher;
LocalCache.Strength keyStrength;
LocalCache.Strength valueStrength;
long expireAfterWriteNanos = -1L;
long expireAfterAccessNanos = -1L;
long refreshNanos = -1L;
Equivalence<Object> keyEquivalence;
Equivalence<Object> valueEquivalence;
RemovalListener<? super K, ? super V> removalListener;
Ticker ticker;
Supplier<? extends AbstractCache.StatsCounter> statsCounterSupplier = NULL_STATS_COUNTER;
CacheBuilder() {
}
public static CacheBuilder<Object, Object> newBuilder() {
return new CacheBuilder<Object, Object>();
}
@Beta
@GwtIncompatible(value="To be supported")
public static CacheBuilder<Object, Object> from(CacheBuilderSpec spec) {
return spec.toCacheBuilder().lenientParsing();
}
@Beta
@GwtIncompatible(value="To be supported")
public static CacheBuilder<Object, Object> from(String spec) {
return CacheBuilder.from(CacheBuilderSpec.parse(spec));
}
@GwtIncompatible(value="To be supported")
CacheBuilder<K, V> lenientParsing() {
this.strictParsing = false;
return this;
}
@GwtIncompatible(value="To be supported")
CacheBuilder<K, V> keyEquivalence(Equivalence<Object> equivalence) {
Preconditions.checkState(this.keyEquivalence == null, "key equivalence was already set to %s", this.keyEquivalence);
this.keyEquivalence = Preconditions.checkNotNull(equivalence);
return this;
}
Equivalence<Object> getKeyEquivalence() {
return MoreObjects.firstNonNull(this.keyEquivalence, this.getKeyStrength().defaultEquivalence());
}
@GwtIncompatible(value="To be supported")
CacheBuilder<K, V> valueEquivalence(Equivalence<Object> equivalence) {
Preconditions.checkState(this.valueEquivalence == null, "value equivalence was already set to %s", this.valueEquivalence);
this.valueEquivalence = Preconditions.checkNotNull(equivalence);
return this;
}
Equivalence<Object> getValueEquivalence() {
return MoreObjects.firstNonNull(this.valueEquivalence, this.getValueStrength().defaultEquivalence());
}
public CacheBuilder<K, V> initialCapacity(int initialCapacity) {
Preconditions.checkState(this.initialCapacity == -1, "initial capacity was already set to %s", this.initialCapacity);
Preconditions.checkArgument(initialCapacity >= 0);
this.initialCapacity = initialCapacity;
return this;
}
int getInitialCapacity() {
return this.initialCapacity == -1 ? 16 : this.initialCapacity;
}
public CacheBuilder<K, V> concurrencyLevel(int concurrencyLevel) {
Preconditions.checkState(this.concurrencyLevel == -1, "concurrency level was already set to %s", this.concurrencyLevel);
Preconditions.checkArgument(concurrencyLevel > 0);
this.concurrencyLevel = concurrencyLevel;
return this;
}
int getConcurrencyLevel() {
return this.concurrencyLevel == -1 ? 4 : this.concurrencyLevel;
}
public CacheBuilder<K, V> maximumSize(long size) {
Preconditions.checkState(this.maximumSize == -1L, "maximum size was already set to %s", this.maximumSize);
Preconditions.checkState(this.maximumWeight == -1L, "maximum weight was already set to %s", this.maximumWeight);
Preconditions.checkState(this.weigher == null, "maximum size can not be combined with weigher");
Preconditions.checkArgument(size >= 0L, "maximum size must not be negative");
this.maximumSize = size;
return this;
}
@GwtIncompatible(value="To be supported")
public CacheBuilder<K, V> maximumWeight(long weight) {
Preconditions.checkState(this.maximumWeight == -1L, "maximum weight was already set to %s", this.maximumWeight);
Preconditions.checkState(this.maximumSize == -1L, "maximum size was already set to %s", this.maximumSize);
this.maximumWeight = weight;
Preconditions.checkArgument(weight >= 0L, "maximum weight must not be negative");
return this;
}
@GwtIncompatible(value="To be supported")
public <K1 extends K, V1 extends V> CacheBuilder<K1, V1> weigher(Weigher<? super K1, ? super V1> weigher) {
Preconditions.checkState(this.weigher == null);
if (this.strictParsing) {
Preconditions.checkState(this.maximumSize == -1L, "weigher can not be combined with maximum size", this.maximumSize);
}
CacheBuilder me = this;
me.weigher = Preconditions.checkNotNull(weigher);
return me;
}
long getMaximumWeight() {
if (this.expireAfterWriteNanos == 0L || this.expireAfterAccessNanos == 0L) {
return 0L;
}
return this.weigher == null ? this.maximumSize : this.maximumWeight;
}
<K1 extends K, V1 extends V> Weigher<K1, V1> getWeigher() {
return MoreObjects.firstNonNull(this.weigher, OneWeigher.INSTANCE);
}
@GwtIncompatible(value="java.lang.ref.WeakReference")
public CacheBuilder<K, V> weakKeys() {
return this.setKeyStrength(LocalCache.Strength.WEAK);
}
CacheBuilder<K, V> setKeyStrength(LocalCache.Strength strength) {
Preconditions.checkState(this.keyStrength == null, "Key strength was already set to %s", new Object[]{this.keyStrength});
this.keyStrength = Preconditions.checkNotNull(strength);
return this;
}
LocalCache.Strength getKeyStrength() {
return MoreObjects.firstNonNull(this.keyStrength, LocalCache.Strength.STRONG);
}
@GwtIncompatible(value="java.lang.ref.WeakReference")
public CacheBuilder<K, V> weakValues() {
return this.setValueStrength(LocalCache.Strength.WEAK);
}
@GwtIncompatible(value="java.lang.ref.SoftReference")
public CacheBuilder<K, V> softValues() {
return this.setValueStrength(LocalCache.Strength.SOFT);
}
CacheBuilder<K, V> setValueStrength(LocalCache.Strength strength) {
Preconditions.checkState(this.valueStrength == null, "Value strength was already set to %s", new Object[]{this.valueStrength});
this.valueStrength = Preconditions.checkNotNull(strength);
return this;
}
LocalCache.Strength getValueStrength() {
return MoreObjects.firstNonNull(this.valueStrength, LocalCache.Strength.STRONG);
}
public CacheBuilder<K, V> expireAfterWrite(long duration, TimeUnit unit) {
Preconditions.checkState(this.expireAfterWriteNanos == -1L, "expireAfterWrite was already set to %s ns", this.expireAfterWriteNanos);
Preconditions.checkArgument(duration >= 0L, "duration cannot be negative: %s %s", new Object[]{duration, unit});
this.expireAfterWriteNanos = unit.toNanos(duration);
return this;
}
long getExpireAfterWriteNanos() {
return this.expireAfterWriteNanos == -1L ? 0L : this.expireAfterWriteNanos;
}
public CacheBuilder<K, V> expireAfterAccess(long duration, TimeUnit unit) {
Preconditions.checkState(this.expireAfterAccessNanos == -1L, "expireAfterAccess was already set to %s ns", this.expireAfterAccessNanos);
Preconditions.checkArgument(duration >= 0L, "duration cannot be negative: %s %s", new Object[]{duration, unit});
this.expireAfterAccessNanos = unit.toNanos(duration);
return this;
}
long getExpireAfterAccessNanos() {
return this.expireAfterAccessNanos == -1L ? 0L : this.expireAfterAccessNanos;
}
@Beta
@GwtIncompatible(value="To be supported (synchronously).")
public CacheBuilder<K, V> refreshAfterWrite(long duration, TimeUnit unit) {
Preconditions.checkNotNull(unit);
Preconditions.checkState(this.refreshNanos == -1L, "refresh was already set to %s ns", this.refreshNanos);
Preconditions.checkArgument(duration > 0L, "duration must be positive: %s %s", new Object[]{duration, unit});
this.refreshNanos = unit.toNanos(duration);
return this;
}
long getRefreshNanos() {
return this.refreshNanos == -1L ? 0L : this.refreshNanos;
}
public CacheBuilder<K, V> ticker(Ticker ticker) {
Preconditions.checkState(this.ticker == null);
this.ticker = Preconditions.checkNotNull(ticker);
return this;
}
Ticker getTicker(boolean recordsTime) {
if (this.ticker != null) {
return this.ticker;
}
return recordsTime ? Ticker.systemTicker() : NULL_TICKER;
}
@CheckReturnValue
public <K1 extends K, V1 extends V> CacheBuilder<K1, V1> removalListener(RemovalListener<? super K1, ? super V1> listener) {
Preconditions.checkState(this.removalListener == null);
CacheBuilder me = this;
me.removalListener = Preconditions.checkNotNull(listener);
return me;
}
<K1 extends K, V1 extends V> RemovalListener<K1, V1> getRemovalListener() {
return MoreObjects.firstNonNull(this.removalListener, NullListener.INSTANCE);
}
public CacheBuilder<K, V> recordStats() {
this.statsCounterSupplier = CACHE_STATS_COUNTER;
return this;
}
boolean isRecordingStats() {
return this.statsCounterSupplier == CACHE_STATS_COUNTER;
}
Supplier<? extends AbstractCache.StatsCounter> getStatsCounterSupplier() {
return this.statsCounterSupplier;
}
public <K1 extends K, V1 extends V> LoadingCache<K1, V1> build(CacheLoader<? super K1, V1> loader) {
this.checkWeightWithWeigher();
return new LocalCache.LocalLoadingCache<K1, V1>(this, loader);
}
public <K1 extends K, V1 extends V> Cache<K1, V1> build() {
this.checkWeightWithWeigher();
this.checkNonLoadingCache();
return new LocalCache.LocalManualCache(this);
}
private void checkNonLoadingCache() {
Preconditions.checkState(this.refreshNanos == -1L, "refreshAfterWrite requires a LoadingCache");
}
private void checkWeightWithWeigher() {
if (this.weigher == null) {
Preconditions.checkState(this.maximumWeight == -1L, "maximumWeight requires weigher");
} else if (this.strictParsing) {
Preconditions.checkState(this.maximumWeight != -1L, "weigher requires maximumWeight");
} else if (this.maximumWeight == -1L) {
logger.log(Level.WARNING, "ignoring weigher specified without maximumWeight");
}
}
public String toString() {
long l;
MoreObjects.ToStringHelper s = MoreObjects.toStringHelper(this);
if (this.initialCapacity != -1) {
s.add("initialCapacity", this.initialCapacity);
}
if (this.concurrencyLevel != -1) {
s.add("concurrencyLevel", this.concurrencyLevel);
}
if (this.maximumSize != -1L) {
s.add("maximumSize", this.maximumSize);
}
if (this.maximumWeight != -1L) {
s.add("maximumWeight", this.maximumWeight);
}
if (this.expireAfterWriteNanos != -1L) {
l = this.expireAfterWriteNanos;
s.add("expireAfterWrite", new StringBuilder(22).append(l).append("ns").toString());
}
if (this.expireAfterAccessNanos != -1L) {
l = this.expireAfterAccessNanos;
s.add("expireAfterAccess", new StringBuilder(22).append(l).append("ns").toString());
}
if (this.keyStrength != null) {
s.add("keyStrength", Ascii.toLowerCase(this.keyStrength.toString()));
}
if (this.valueStrength != null) {
s.add("valueStrength", Ascii.toLowerCase(this.valueStrength.toString()));
}
if (this.keyEquivalence != null) {
s.addValue("keyEquivalence");
}
if (this.valueEquivalence != null) {
s.addValue("valueEquivalence");
}
if (this.removalListener != null) {
s.addValue("removalListener");
}
return s.toString();
}
static enum OneWeigher implements Weigher<Object, Object>
{
INSTANCE;
@Override
public int weigh(Object key, Object value) {
return 1;
}
}
static enum NullListener implements RemovalListener<Object, Object>
{
INSTANCE;
@Override
public void onRemoval(RemovalNotification<Object, Object> notification) {
}
}
}

View file

@ -0,0 +1,378 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.cache;
import com.google.common.annotations.Beta;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.LocalCache;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
@Beta
public final class CacheBuilderSpec {
private static final Splitter KEYS_SPLITTER = Splitter.on(',').trimResults();
private static final Splitter KEY_VALUE_SPLITTER = Splitter.on('=').trimResults();
private static final ImmutableMap<String, ValueParser> VALUE_PARSERS = ImmutableMap.builder().put("initialCapacity", new InitialCapacityParser()).put("maximumSize", (InitialCapacityParser)((Object)new MaximumSizeParser())).put("maximumWeight", (InitialCapacityParser)((Object)new MaximumWeightParser())).put("concurrencyLevel", (InitialCapacityParser)((Object)new ConcurrencyLevelParser())).put("weakKeys", (InitialCapacityParser)((Object)new KeyStrengthParser(LocalCache.Strength.WEAK))).put("softValues", (InitialCapacityParser)((Object)new ValueStrengthParser(LocalCache.Strength.SOFT))).put("weakValues", (InitialCapacityParser)((Object)new ValueStrengthParser(LocalCache.Strength.WEAK))).put("recordStats", (InitialCapacityParser)((Object)new RecordStatsParser())).put("expireAfterAccess", (InitialCapacityParser)((Object)new AccessDurationParser())).put("expireAfterWrite", (InitialCapacityParser)((Object)new WriteDurationParser())).put("refreshAfterWrite", (InitialCapacityParser)((Object)new RefreshDurationParser())).put("refreshInterval", (InitialCapacityParser)((Object)new RefreshDurationParser())).build();
@VisibleForTesting
Integer initialCapacity;
@VisibleForTesting
Long maximumSize;
@VisibleForTesting
Long maximumWeight;
@VisibleForTesting
Integer concurrencyLevel;
@VisibleForTesting
LocalCache.Strength keyStrength;
@VisibleForTesting
LocalCache.Strength valueStrength;
@VisibleForTesting
Boolean recordStats;
@VisibleForTesting
long writeExpirationDuration;
@VisibleForTesting
TimeUnit writeExpirationTimeUnit;
@VisibleForTesting
long accessExpirationDuration;
@VisibleForTesting
TimeUnit accessExpirationTimeUnit;
@VisibleForTesting
long refreshDuration;
@VisibleForTesting
TimeUnit refreshTimeUnit;
private final String specification;
private CacheBuilderSpec(String specification) {
this.specification = specification;
}
public static CacheBuilderSpec parse(String cacheBuilderSpecification) {
CacheBuilderSpec spec = new CacheBuilderSpec(cacheBuilderSpecification);
if (!cacheBuilderSpecification.isEmpty()) {
for (String keyValuePair : KEYS_SPLITTER.split(cacheBuilderSpecification)) {
ImmutableList<String> keyAndValue = ImmutableList.copyOf(KEY_VALUE_SPLITTER.split(keyValuePair));
Preconditions.checkArgument(!keyAndValue.isEmpty(), "blank key-value pair");
Preconditions.checkArgument(keyAndValue.size() <= 2, "key-value pair %s with more than one equals sign", keyValuePair);
String key = (String)keyAndValue.get(0);
ValueParser valueParser = VALUE_PARSERS.get(key);
Preconditions.checkArgument(valueParser != null, "unknown key %s", key);
String value = keyAndValue.size() == 1 ? null : (String)keyAndValue.get(1);
valueParser.parse(spec, key, value);
}
}
return spec;
}
public static CacheBuilderSpec disableCaching() {
return CacheBuilderSpec.parse("maximumSize=0");
}
CacheBuilder<Object, Object> toCacheBuilder() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();
if (this.initialCapacity != null) {
builder.initialCapacity(this.initialCapacity);
}
if (this.maximumSize != null) {
builder.maximumSize(this.maximumSize);
}
if (this.maximumWeight != null) {
builder.maximumWeight(this.maximumWeight);
}
if (this.concurrencyLevel != null) {
builder.concurrencyLevel(this.concurrencyLevel);
}
if (this.keyStrength != null) {
switch (this.keyStrength) {
case WEAK: {
builder.weakKeys();
break;
}
default: {
throw new AssertionError();
}
}
}
if (this.valueStrength != null) {
switch (this.valueStrength) {
case SOFT: {
builder.softValues();
break;
}
case WEAK: {
builder.weakValues();
break;
}
default: {
throw new AssertionError();
}
}
}
if (this.recordStats != null && this.recordStats.booleanValue()) {
builder.recordStats();
}
if (this.writeExpirationTimeUnit != null) {
builder.expireAfterWrite(this.writeExpirationDuration, this.writeExpirationTimeUnit);
}
if (this.accessExpirationTimeUnit != null) {
builder.expireAfterAccess(this.accessExpirationDuration, this.accessExpirationTimeUnit);
}
if (this.refreshTimeUnit != null) {
builder.refreshAfterWrite(this.refreshDuration, this.refreshTimeUnit);
}
return builder;
}
public String toParsableString() {
return this.specification;
}
public String toString() {
return MoreObjects.toStringHelper(this).addValue(this.toParsableString()).toString();
}
public int hashCode() {
return Objects.hashCode(new Object[]{this.initialCapacity, this.maximumSize, this.maximumWeight, this.concurrencyLevel, this.keyStrength, this.valueStrength, this.recordStats, CacheBuilderSpec.durationInNanos(this.writeExpirationDuration, this.writeExpirationTimeUnit), CacheBuilderSpec.durationInNanos(this.accessExpirationDuration, this.accessExpirationTimeUnit), CacheBuilderSpec.durationInNanos(this.refreshDuration, this.refreshTimeUnit)});
}
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof CacheBuilderSpec)) {
return false;
}
CacheBuilderSpec that = (CacheBuilderSpec)obj;
return Objects.equal(this.initialCapacity, that.initialCapacity) && Objects.equal(this.maximumSize, that.maximumSize) && Objects.equal(this.maximumWeight, that.maximumWeight) && Objects.equal(this.concurrencyLevel, that.concurrencyLevel) && Objects.equal((Object)this.keyStrength, (Object)that.keyStrength) && Objects.equal((Object)this.valueStrength, (Object)that.valueStrength) && Objects.equal(this.recordStats, that.recordStats) && Objects.equal(CacheBuilderSpec.durationInNanos(this.writeExpirationDuration, this.writeExpirationTimeUnit), CacheBuilderSpec.durationInNanos(that.writeExpirationDuration, that.writeExpirationTimeUnit)) && Objects.equal(CacheBuilderSpec.durationInNanos(this.accessExpirationDuration, this.accessExpirationTimeUnit), CacheBuilderSpec.durationInNanos(that.accessExpirationDuration, that.accessExpirationTimeUnit)) && Objects.equal(CacheBuilderSpec.durationInNanos(this.refreshDuration, this.refreshTimeUnit), CacheBuilderSpec.durationInNanos(that.refreshDuration, that.refreshTimeUnit));
}
@Nullable
private static Long durationInNanos(long duration, @Nullable TimeUnit unit) {
return unit == null ? null : Long.valueOf(unit.toNanos(duration));
}
static class RefreshDurationParser
extends DurationParser {
RefreshDurationParser() {
}
@Override
protected void parseDuration(CacheBuilderSpec spec, long duration, TimeUnit unit) {
Preconditions.checkArgument(spec.refreshTimeUnit == null, "refreshAfterWrite already set");
spec.refreshDuration = duration;
spec.refreshTimeUnit = unit;
}
}
static class WriteDurationParser
extends DurationParser {
WriteDurationParser() {
}
@Override
protected void parseDuration(CacheBuilderSpec spec, long duration, TimeUnit unit) {
Preconditions.checkArgument(spec.writeExpirationTimeUnit == null, "expireAfterWrite already set");
spec.writeExpirationDuration = duration;
spec.writeExpirationTimeUnit = unit;
}
}
static class AccessDurationParser
extends DurationParser {
AccessDurationParser() {
}
@Override
protected void parseDuration(CacheBuilderSpec spec, long duration, TimeUnit unit) {
Preconditions.checkArgument(spec.accessExpirationTimeUnit == null, "expireAfterAccess already set");
spec.accessExpirationDuration = duration;
spec.accessExpirationTimeUnit = unit;
}
}
static abstract class DurationParser
implements ValueParser {
DurationParser() {
}
protected abstract void parseDuration(CacheBuilderSpec var1, long var2, TimeUnit var4);
@Override
public void parse(CacheBuilderSpec spec, String key, String value) {
Preconditions.checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
try {
TimeUnit timeUnit;
char lastChar = value.charAt(value.length() - 1);
switch (lastChar) {
case 'd': {
timeUnit = TimeUnit.DAYS;
break;
}
case 'h': {
timeUnit = TimeUnit.HOURS;
break;
}
case 'm': {
timeUnit = TimeUnit.MINUTES;
break;
}
case 's': {
timeUnit = TimeUnit.SECONDS;
break;
}
default: {
throw new IllegalArgumentException(String.format("key %s invalid format. was %s, must end with one of [dDhHmMsS]", key, value));
}
}
long duration = Long.parseLong(value.substring(0, value.length() - 1));
this.parseDuration(spec, duration, timeUnit);
}
catch (NumberFormatException e) {
throw new IllegalArgumentException(String.format("key %s value set to %s, must be integer", key, value));
}
}
}
static class RecordStatsParser
implements ValueParser {
RecordStatsParser() {
}
@Override
public void parse(CacheBuilderSpec spec, String key, @Nullable String value) {
Preconditions.checkArgument(value == null, "recordStats does not take values");
Preconditions.checkArgument(spec.recordStats == null, "recordStats already set");
spec.recordStats = true;
}
}
static class ValueStrengthParser
implements ValueParser {
private final LocalCache.Strength strength;
public ValueStrengthParser(LocalCache.Strength strength) {
this.strength = strength;
}
@Override
public void parse(CacheBuilderSpec spec, String key, @Nullable String value) {
Preconditions.checkArgument(value == null, "key %s does not take values", key);
Preconditions.checkArgument(spec.valueStrength == null, "%s was already set to %s", new Object[]{key, spec.valueStrength});
spec.valueStrength = this.strength;
}
}
static class KeyStrengthParser
implements ValueParser {
private final LocalCache.Strength strength;
public KeyStrengthParser(LocalCache.Strength strength) {
this.strength = strength;
}
@Override
public void parse(CacheBuilderSpec spec, String key, @Nullable String value) {
Preconditions.checkArgument(value == null, "key %s does not take values", key);
Preconditions.checkArgument(spec.keyStrength == null, "%s was already set to %s", new Object[]{key, spec.keyStrength});
spec.keyStrength = this.strength;
}
}
static class ConcurrencyLevelParser
extends IntegerParser {
ConcurrencyLevelParser() {
}
@Override
protected void parseInteger(CacheBuilderSpec spec, int value) {
Preconditions.checkArgument(spec.concurrencyLevel == null, "concurrency level was already set to ", spec.concurrencyLevel);
spec.concurrencyLevel = value;
}
}
static class MaximumWeightParser
extends LongParser {
MaximumWeightParser() {
}
@Override
protected void parseLong(CacheBuilderSpec spec, long value) {
Preconditions.checkArgument(spec.maximumWeight == null, "maximum weight was already set to ", spec.maximumWeight);
Preconditions.checkArgument(spec.maximumSize == null, "maximum size was already set to ", spec.maximumSize);
spec.maximumWeight = value;
}
}
static class MaximumSizeParser
extends LongParser {
MaximumSizeParser() {
}
@Override
protected void parseLong(CacheBuilderSpec spec, long value) {
Preconditions.checkArgument(spec.maximumSize == null, "maximum size was already set to ", spec.maximumSize);
Preconditions.checkArgument(spec.maximumWeight == null, "maximum weight was already set to ", spec.maximumWeight);
spec.maximumSize = value;
}
}
static class InitialCapacityParser
extends IntegerParser {
InitialCapacityParser() {
}
@Override
protected void parseInteger(CacheBuilderSpec spec, int value) {
Preconditions.checkArgument(spec.initialCapacity == null, "initial capacity was already set to ", spec.initialCapacity);
spec.initialCapacity = value;
}
}
static abstract class LongParser
implements ValueParser {
LongParser() {
}
protected abstract void parseLong(CacheBuilderSpec var1, long var2);
@Override
public void parse(CacheBuilderSpec spec, String key, String value) {
Preconditions.checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
try {
this.parseLong(spec, Long.parseLong(value));
}
catch (NumberFormatException e) {
throw new IllegalArgumentException(String.format("key %s value set to %s, must be integer", key, value), e);
}
}
}
static abstract class IntegerParser
implements ValueParser {
IntegerParser() {
}
protected abstract void parseInteger(CacheBuilderSpec var1, int var2);
@Override
public void parse(CacheBuilderSpec spec, String key, String value) {
Preconditions.checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
try {
this.parseInteger(spec, Integer.parseInt(value));
}
catch (NumberFormatException e) {
throw new IllegalArgumentException(String.format("key %s value set to %s, must be integer", key, value), e);
}
}
}
private static interface ValueParser {
public void parse(CacheBuilderSpec var1, String var2, @Nullable String var3);
}
}

View file

@ -0,0 +1,125 @@
/*
* Decompiled with CFR 0.152.
*/
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> {
protected CacheLoader() {
}
public abstract V load(K var1) throws Exception;
@GwtIncompatible(value="Futures")
public ListenableFuture<V> reload(K key, V oldValue) throws Exception {
Preconditions.checkNotNull(key);
Preconditions.checkNotNull(oldValue);
return Futures.immediateFuture(this.load(key));
}
public Map<K, V> loadAll(Iterable<? extends K> keys) throws Exception {
throw new UnsupportedLoadingOperationException();
}
@Beta
public static <K, V> CacheLoader<K, V> from(Function<K, V> function) {
return new FunctionToCacheLoader<K, V>(function);
}
@Beta
public static <V> CacheLoader<Object, V> from(Supplier<V> supplier) {
return new SupplierToCacheLoader<V>(supplier);
}
@Beta
@GwtIncompatible(value="Executor + Futures")
public static <K, V> CacheLoader<K, V> asyncReloading(final CacheLoader<K, V> loader, final Executor executor) {
Preconditions.checkNotNull(loader);
Preconditions.checkNotNull(executor);
return new CacheLoader<K, V>(){
@Override
public V load(K key) throws Exception {
return loader.load(key);
}
@Override
public ListenableFuture<V> reload(final K key, final V oldValue) throws Exception {
ListenableFutureTask task = ListenableFutureTask.create(new Callable<V>(){
@Override
public V call() throws Exception {
return loader.reload(key, oldValue).get();
}
});
executor.execute(task);
return task;
}
@Override
public Map<K, V> loadAll(Iterable<? extends K> keys) throws Exception {
return loader.loadAll(keys);
}
};
}
public static final class InvalidCacheLoadException
extends RuntimeException {
public InvalidCacheLoadException(String message) {
super(message);
}
}
static final class UnsupportedLoadingOperationException
extends UnsupportedOperationException {
UnsupportedLoadingOperationException() {
}
}
private static final class SupplierToCacheLoader<V>
extends CacheLoader<Object, V>
implements Serializable {
private final Supplier<V> computingSupplier;
private static final long serialVersionUID = 0L;
public SupplierToCacheLoader(Supplier<V> computingSupplier) {
this.computingSupplier = Preconditions.checkNotNull(computingSupplier);
}
@Override
public V load(Object key) {
Preconditions.checkNotNull(key);
return this.computingSupplier.get();
}
}
private static final class FunctionToCacheLoader<K, V>
extends CacheLoader<K, V>
implements Serializable {
private final Function<K, V> computingFunction;
private static final long serialVersionUID = 0L;
public FunctionToCacheLoader(Function<K, V> computingFunction) {
this.computingFunction = Preconditions.checkNotNull(computingFunction);
}
@Override
public V load(K key) {
return this.computingFunction.apply(Preconditions.checkNotNull(key));
}
}
}

View file

@ -0,0 +1,113 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.cache;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import javax.annotation.Nullable;
@Beta
@GwtCompatible
public final class CacheStats {
private final long hitCount;
private final long missCount;
private final long loadSuccessCount;
private final long loadExceptionCount;
private final long totalLoadTime;
private final long evictionCount;
public CacheStats(long hitCount, long missCount, long loadSuccessCount, long loadExceptionCount, long totalLoadTime, long evictionCount) {
Preconditions.checkArgument(hitCount >= 0L);
Preconditions.checkArgument(missCount >= 0L);
Preconditions.checkArgument(loadSuccessCount >= 0L);
Preconditions.checkArgument(loadExceptionCount >= 0L);
Preconditions.checkArgument(totalLoadTime >= 0L);
Preconditions.checkArgument(evictionCount >= 0L);
this.hitCount = hitCount;
this.missCount = missCount;
this.loadSuccessCount = loadSuccessCount;
this.loadExceptionCount = loadExceptionCount;
this.totalLoadTime = totalLoadTime;
this.evictionCount = evictionCount;
}
public long requestCount() {
return this.hitCount + this.missCount;
}
public long hitCount() {
return this.hitCount;
}
public double hitRate() {
long requestCount = this.requestCount();
return requestCount == 0L ? 1.0 : (double)this.hitCount / (double)requestCount;
}
public long missCount() {
return this.missCount;
}
public double missRate() {
long requestCount = this.requestCount();
return requestCount == 0L ? 0.0 : (double)this.missCount / (double)requestCount;
}
public long loadCount() {
return this.loadSuccessCount + this.loadExceptionCount;
}
public long loadSuccessCount() {
return this.loadSuccessCount;
}
public long loadExceptionCount() {
return this.loadExceptionCount;
}
public double loadExceptionRate() {
long totalLoadCount = this.loadSuccessCount + this.loadExceptionCount;
return totalLoadCount == 0L ? 0.0 : (double)this.loadExceptionCount / (double)totalLoadCount;
}
public long totalLoadTime() {
return this.totalLoadTime;
}
public double averageLoadPenalty() {
long totalLoadCount = this.loadSuccessCount + this.loadExceptionCount;
return totalLoadCount == 0L ? 0.0 : (double)this.totalLoadTime / (double)totalLoadCount;
}
public long evictionCount() {
return this.evictionCount;
}
public CacheStats minus(CacheStats other) {
return new CacheStats(Math.max(0L, this.hitCount - other.hitCount), Math.max(0L, this.missCount - other.missCount), Math.max(0L, this.loadSuccessCount - other.loadSuccessCount), Math.max(0L, this.loadExceptionCount - other.loadExceptionCount), Math.max(0L, this.totalLoadTime - other.totalLoadTime), Math.max(0L, this.evictionCount - other.evictionCount));
}
public CacheStats plus(CacheStats other) {
return new CacheStats(this.hitCount + other.hitCount, this.missCount + other.missCount, this.loadSuccessCount + other.loadSuccessCount, this.loadExceptionCount + other.loadExceptionCount, this.totalLoadTime + other.totalLoadTime, this.evictionCount + other.evictionCount);
}
public int hashCode() {
return Objects.hashCode(this.hitCount, this.missCount, this.loadSuccessCount, this.loadExceptionCount, this.totalLoadTime, this.evictionCount);
}
public boolean equals(@Nullable Object object) {
if (object instanceof CacheStats) {
CacheStats other = (CacheStats)object;
return this.hitCount == other.hitCount && this.missCount == other.missCount && this.loadSuccessCount == other.loadSuccessCount && this.loadExceptionCount == other.loadExceptionCount && this.totalLoadTime == other.totalLoadTime && this.evictionCount == other.evictionCount;
}
return false;
}
public String toString() {
return MoreObjects.toStringHelper(this).add("hitCount", this.hitCount).add("missCount", this.missCount).add("loadSuccessCount", this.loadSuccessCount).add("loadExceptionCount", this.loadExceptionCount).add("totalLoadTime", this.totalLoadTime).add("evictionCount", this.evictionCount).toString();
}
}

View file

@ -0,0 +1,103 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.cache;
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheStats;
import com.google.common.collect.ForwardingObject;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
import javax.annotation.Nullable;
@Beta
public abstract class ForwardingCache<K, V>
extends ForwardingObject
implements Cache<K, V> {
protected ForwardingCache() {
}
@Override
protected abstract Cache<K, V> delegate();
@Override
@Nullable
public V getIfPresent(Object key) {
return this.delegate().getIfPresent(key);
}
@Override
public V get(K key, Callable<? extends V> valueLoader) throws ExecutionException {
return this.delegate().get(key, valueLoader);
}
@Override
public ImmutableMap<K, V> getAllPresent(Iterable<?> keys) {
return this.delegate().getAllPresent(keys);
}
@Override
public void put(K key, V value) {
this.delegate().put(key, value);
}
@Override
public void putAll(Map<? extends K, ? extends V> m) {
this.delegate().putAll(m);
}
@Override
public void invalidate(Object key) {
this.delegate().invalidate(key);
}
@Override
public void invalidateAll(Iterable<?> keys) {
this.delegate().invalidateAll(keys);
}
@Override
public void invalidateAll() {
this.delegate().invalidateAll();
}
@Override
public long size() {
return this.delegate().size();
}
@Override
public CacheStats stats() {
return this.delegate().stats();
}
@Override
public ConcurrentMap<K, V> asMap() {
return this.delegate().asMap();
}
@Override
public void cleanUp() {
this.delegate().cleanUp();
}
@Beta
public static abstract class SimpleForwardingCache<K, V>
extends ForwardingCache<K, V> {
private final Cache<K, V> delegate;
protected SimpleForwardingCache(Cache<K, V> delegate) {
this.delegate = Preconditions.checkNotNull(delegate);
}
@Override
protected final Cache<K, V> delegate() {
return this.delegate;
}
}
}

View file

@ -0,0 +1,62 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.cache;
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import com.google.common.cache.ForwardingCache;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMap;
import java.util.concurrent.ExecutionException;
@Beta
public abstract class ForwardingLoadingCache<K, V>
extends ForwardingCache<K, V>
implements LoadingCache<K, V> {
protected ForwardingLoadingCache() {
}
@Override
protected abstract LoadingCache<K, V> delegate();
@Override
public V get(K key) throws ExecutionException {
return this.delegate().get(key);
}
@Override
public V getUnchecked(K key) {
return this.delegate().getUnchecked(key);
}
@Override
public ImmutableMap<K, V> getAll(Iterable<? extends K> keys) throws ExecutionException {
return this.delegate().getAll(keys);
}
@Override
public V apply(K key) {
return this.delegate().apply(key);
}
@Override
public void refresh(K key) {
this.delegate().refresh(key);
}
@Beta
public static abstract class SimpleForwardingLoadingCache<K, V>
extends ForwardingLoadingCache<K, V> {
private final LoadingCache<K, V> delegate;
protected SimpleForwardingLoadingCache(LoadingCache<K, V> delegate) {
this.delegate = Preconditions.checkNotNull(delegate);
}
@Override
protected final LoadingCache<K, V> delegate() {
return this.delegate;
}
}
}

View file

@ -0,0 +1,33 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.cache;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Function;
import com.google.common.cache.Cache;
import com.google.common.collect.ImmutableMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
@Beta
@GwtCompatible
public interface LoadingCache<K, V>
extends Cache<K, V>,
Function<K, V> {
public V get(K var1) throws ExecutionException;
public V getUnchecked(K var1);
public ImmutableMap<K, V> getAll(Iterable<? extends K> var1) throws ExecutionException;
@Override
@Deprecated
public V apply(K var1);
public void refresh(K var1);
@Override
public ConcurrentMap<K, V> asMap();
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,15 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.cache;
import com.google.common.annotations.GwtCompatible;
@GwtCompatible
interface LongAddable {
public void increment();
public void add(long var1);
public long sum();
}

View file

@ -0,0 +1,68 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.cache;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Supplier;
import com.google.common.cache.LongAddable;
import com.google.common.cache.LongAdder;
import java.util.concurrent.atomic.AtomicLong;
@GwtCompatible(emulated=true)
final class LongAddables {
private static final Supplier<LongAddable> SUPPLIER;
LongAddables() {
}
public static LongAddable create() {
return SUPPLIER.get();
}
static {
Supplier<LongAddable> supplier;
try {
new LongAdder();
supplier = new Supplier<LongAddable>(){
@Override
public LongAddable get() {
return new LongAdder();
}
};
}
catch (Throwable t) {
supplier = new Supplier<LongAddable>(){
@Override
public LongAddable get() {
return new PureJavaLongAddable();
}
};
}
SUPPLIER = supplier;
}
private static final class PureJavaLongAddable
extends AtomicLong
implements LongAddable {
private PureJavaLongAddable() {
}
@Override
public void increment() {
this.getAndIncrement();
}
@Override
public void add(long x) {
this.getAndAdd(x);
}
@Override
public long sum() {
return this.get();
}
}
}

View file

@ -0,0 +1,117 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.cache;
import com.google.common.annotations.GwtCompatible;
import com.google.common.cache.LongAddable;
import com.google.common.cache.Striped64;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
@GwtCompatible(emulated=true)
final class LongAdder
extends Striped64
implements Serializable,
LongAddable {
private static final long serialVersionUID = 7249069246863182397L;
@Override
final long fn(long v, long x) {
return v + x;
}
@Override
public void add(long x) {
long b;
Striped64.Cell[] as = this.cells;
if (this.cells != null || !this.casBase(b = this.base, b + x)) {
long v;
Striped64.Cell a;
int n;
boolean uncontended = true;
int[] hc = (int[])threadHashCode.get();
if (hc == null || as == null || (n = as.length) < 1 || (a = as[n - 1 & hc[0]]) == null || !(uncontended = a.cas(v = a.value, v + x))) {
this.retryUpdate(x, hc, uncontended);
}
}
}
@Override
public void increment() {
this.add(1L);
}
public void decrement() {
this.add(-1L);
}
@Override
public long sum() {
long sum = this.base;
Striped64.Cell[] as = this.cells;
if (as != null) {
for (Striped64.Cell a : as) {
if (a == null) continue;
sum += a.value;
}
}
return sum;
}
public void reset() {
this.internalReset(0L);
}
public long sumThenReset() {
long sum = this.base;
Striped64.Cell[] as = this.cells;
this.base = 0L;
if (as != null) {
for (Striped64.Cell a : as) {
if (a == null) continue;
sum += a.value;
a.value = 0L;
}
}
return sum;
}
public String toString() {
return Long.toString(this.sum());
}
@Override
public long longValue() {
return this.sum();
}
@Override
public int intValue() {
return (int)this.sum();
}
@Override
public float floatValue() {
return this.sum();
}
@Override
public double doubleValue() {
return this.sum();
}
private void writeObject(ObjectOutputStream s) throws IOException {
s.defaultWriteObject();
s.writeLong(this.sum());
}
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
s.defaultReadObject();
this.busy = 0;
this.cells = null;
this.base = s.readLong();
}
}

View file

@ -0,0 +1,54 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.cache;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@Beta
@GwtCompatible
public enum RemovalCause {
EXPLICIT{
@Override
boolean wasEvicted() {
return false;
}
}
,
REPLACED{
@Override
boolean wasEvicted() {
return false;
}
}
,
COLLECTED{
@Override
boolean wasEvicted() {
return true;
}
}
,
EXPIRED{
@Override
boolean wasEvicted() {
return true;
}
}
,
SIZE{
@Override
boolean wasEvicted() {
return true;
}
};
abstract boolean wasEvicted();
}

View file

@ -0,0 +1,14 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.cache;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.cache.RemovalNotification;
@Beta
@GwtCompatible
public interface RemovalListener<K, V> {
public void onRemoval(RemovalNotification<K, V> var1);
}

View file

@ -0,0 +1,34 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.cache;
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import com.google.common.cache.RemovalListener;
import com.google.common.cache.RemovalNotification;
import java.util.concurrent.Executor;
@Beta
public final class RemovalListeners {
private RemovalListeners() {
}
public static <K, V> RemovalListener<K, V> asynchronous(final RemovalListener<K, V> listener, final Executor executor) {
Preconditions.checkNotNull(listener);
Preconditions.checkNotNull(executor);
return new RemovalListener<K, V>(){
@Override
public void onRemoval(final RemovalNotification<K, V> notification) {
executor.execute(new Runnable(){
@Override
public void run() {
listener.onRemoval(notification);
}
});
}
};
}
}

View file

@ -0,0 +1,77 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.cache;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.cache.RemovalCause;
import java.util.Map;
import javax.annotation.Nullable;
@Beta
@GwtCompatible
public final class RemovalNotification<K, V>
implements Map.Entry<K, V> {
@Nullable
private final K key;
@Nullable
private final V value;
private final RemovalCause cause;
private static final long serialVersionUID = 0L;
RemovalNotification(@Nullable K key, @Nullable V value, RemovalCause cause) {
this.key = key;
this.value = value;
this.cause = Preconditions.checkNotNull(cause);
}
public RemovalCause getCause() {
return this.cause;
}
public boolean wasEvicted() {
return this.cause.wasEvicted();
}
@Override
@Nullable
public K getKey() {
return this.key;
}
@Override
@Nullable
public V getValue() {
return this.value;
}
@Override
public final V setValue(V value) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(@Nullable Object object) {
if (object instanceof Map.Entry) {
Map.Entry that = (Map.Entry)object;
return Objects.equal(this.getKey(), that.getKey()) && Objects.equal(this.getValue(), that.getValue());
}
return false;
}
@Override
public int hashCode() {
K k = this.getKey();
V v = this.getValue();
return (k == null ? 0 : k.hashCode()) ^ (v == null ? 0 : v.hashCode());
}
public String toString() {
String string = String.valueOf(String.valueOf(this.getKey()));
String string2 = String.valueOf(String.valueOf(this.getValue()));
return new StringBuilder(1 + string.length() + string2.length()).append(string).append("=").append(string2).toString();
}
}

View file

@ -0,0 +1,224 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.cache;
import java.lang.reflect.Field;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Random;
import sun.misc.Unsafe;
abstract class Striped64
extends Number {
static final ThreadLocal<int[]> threadHashCode = new ThreadLocal();
static final Random rng = new Random();
static final int NCPU = Runtime.getRuntime().availableProcessors();
volatile transient Cell[] cells;
volatile transient long base;
volatile transient int busy;
private static final Unsafe UNSAFE;
private static final long baseOffset;
private static final long busyOffset;
Striped64() {
}
final boolean casBase(long cmp, long val) {
return UNSAFE.compareAndSwapLong(this, baseOffset, cmp, val);
}
final boolean casBusy() {
return UNSAFE.compareAndSwapInt(this, busyOffset, 0, 1);
}
abstract long fn(long var1, long var3);
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled force condition propagation
* Lifted jumps to return sites
*/
final void retryUpdate(long x, int[] hc, boolean wasUncontended) {
int h;
if (hc == null) {
hc = new int[1];
threadHashCode.set(hc);
int r = rng.nextInt();
hc[0] = r == 0 ? 1 : r;
h = hc[0];
} else {
h = hc[0];
}
boolean collide = false;
while (true) {
long v;
int n;
Cell[] as = this.cells;
if (this.cells != null && (n = as.length) > 0) {
Cell a = as[n - 1 & h];
if (a == null) {
if (this.busy == 0) {
Cell r = new Cell(x);
if (this.busy == 0 && this.casBusy()) {
boolean created = false;
try {
int j;
int m;
Cell[] rs = this.cells;
if (this.cells != null && (m = rs.length) > 0 && rs[j = m - 1 & h] == null) {
rs[j] = r;
created = true;
}
}
finally {
this.busy = 0;
}
if (!created) continue;
return;
}
}
collide = false;
} else if (!wasUncontended) {
wasUncontended = true;
} else {
v = a.value;
if (a.cas(v, this.fn(v, x))) return;
if (n >= NCPU || this.cells != as) {
collide = false;
} else if (!collide) {
collide = true;
} else if (this.busy == 0 && this.casBusy()) {
try {
if (this.cells == as) {
Cell[] rs = new Cell[n << 1];
for (int i = 0; i < n; ++i) {
rs[i] = as[i];
}
this.cells = rs;
}
}
finally {
this.busy = 0;
}
collide = false;
continue;
}
}
h ^= h << 13;
h ^= h >>> 17;
h ^= h << 5;
hc[0] = h;
continue;
}
if (this.busy == 0 && this.cells == as && this.casBusy()) {
boolean init = false;
try {
if (this.cells == as) {
Cell[] rs = new Cell[2];
rs[h & 1] = new Cell(x);
this.cells = rs;
init = true;
}
}
finally {
this.busy = 0;
}
if (!init) continue;
return;
}
v = this.base;
if (this.casBase(v, this.fn(v, x))) return;
}
}
final void internalReset(long initialValue) {
Cell[] as = this.cells;
this.base = initialValue;
if (as != null) {
for (Cell a : as) {
if (a == null) continue;
a.value = initialValue;
}
}
}
private static Unsafe getUnsafe() {
try {
return Unsafe.getUnsafe();
}
catch (SecurityException tryReflectionInstead) {
try {
return AccessController.doPrivileged(new PrivilegedExceptionAction<Unsafe>(){
@Override
public Unsafe run() throws Exception {
Class<Unsafe> k = Unsafe.class;
for (Field f : k.getDeclaredFields()) {
f.setAccessible(true);
Object x = f.get(null);
if (!k.isInstance(x)) continue;
return (Unsafe)k.cast(x);
}
throw new NoSuchFieldError("the Unsafe");
}
});
}
catch (PrivilegedActionException e) {
throw new RuntimeException("Could not initialize intrinsics", e.getCause());
}
}
}
static {
try {
UNSAFE = Striped64.getUnsafe();
Class<Striped64> sk = Striped64.class;
baseOffset = UNSAFE.objectFieldOffset(sk.getDeclaredField("base"));
busyOffset = UNSAFE.objectFieldOffset(sk.getDeclaredField("busy"));
}
catch (Exception e) {
throw new Error(e);
}
}
static final class Cell {
volatile long p0;
volatile long p1;
volatile long p2;
volatile long p3;
volatile long p4;
volatile long p5;
volatile long p6;
volatile long value;
volatile long q0;
volatile long q1;
volatile long q2;
volatile long q3;
volatile long q4;
volatile long q5;
volatile long q6;
private static final Unsafe UNSAFE;
private static final long valueOffset;
Cell(long x) {
this.value = x;
}
final boolean cas(long cmp, long val) {
return UNSAFE.compareAndSwapLong(this, valueOffset, cmp, val);
}
static {
try {
UNSAFE = Striped64.getUnsafe();
Class<Cell> ak = Cell.class;
valueOffset = UNSAFE.objectFieldOffset(ak.getDeclaredField("value"));
}
catch (Exception e) {
throw new Error(e);
}
}
}
}

View file

@ -0,0 +1,13 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.cache;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
@Beta
@GwtCompatible
public interface Weigher<K, V> {
public int weigh(K var1, V var2);
}

View file

@ -0,0 +1,8 @@
/*
* Decompiled with CFR 0.152.
*/
@ParametersAreNonnullByDefault
package com.google.common.cache;
import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -0,0 +1,382 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.collect.BiMap;
import com.google.common.collect.CollectPreconditions;
import com.google.common.collect.ForwardingMap;
import com.google.common.collect.ForwardingMapEntry;
import com.google.common.collect.ForwardingSet;
import com.google.common.collect.Maps;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
@GwtCompatible(emulated=true)
abstract class AbstractBiMap<K, V>
extends ForwardingMap<K, V>
implements BiMap<K, V>,
Serializable {
private transient Map<K, V> delegate;
transient AbstractBiMap<V, K> inverse;
private transient Set<K> keySet;
private transient Set<V> valueSet;
private transient Set<Map.Entry<K, V>> entrySet;
@GwtIncompatible(value="Not needed in emulated source.")
private static final long serialVersionUID = 0L;
AbstractBiMap(Map<K, V> forward, Map<V, K> backward) {
this.setDelegates(forward, backward);
}
private AbstractBiMap(Map<K, V> backward, AbstractBiMap<V, K> forward) {
this.delegate = backward;
this.inverse = forward;
}
@Override
protected Map<K, V> delegate() {
return this.delegate;
}
K checkKey(@Nullable K key) {
return key;
}
V checkValue(@Nullable V value) {
return value;
}
void setDelegates(Map<K, V> forward, Map<V, K> backward) {
Preconditions.checkState(this.delegate == null);
Preconditions.checkState(this.inverse == null);
Preconditions.checkArgument(forward.isEmpty());
Preconditions.checkArgument(backward.isEmpty());
Preconditions.checkArgument(forward != backward);
this.delegate = forward;
this.inverse = new Inverse<V, K>(backward, this);
}
void setInverse(AbstractBiMap<V, K> inverse) {
this.inverse = inverse;
}
@Override
public boolean containsValue(@Nullable Object value) {
return this.inverse.containsKey(value);
}
@Override
public V put(@Nullable K key, @Nullable V value) {
return this.putInBothMaps(key, value, false);
}
@Override
public V forcePut(@Nullable K key, @Nullable V value) {
return this.putInBothMaps(key, value, true);
}
private V putInBothMaps(@Nullable K key, @Nullable V value, boolean force) {
this.checkKey(key);
this.checkValue(value);
boolean containedKey = this.containsKey(key);
if (containedKey && Objects.equal(value, this.get(key))) {
return value;
}
if (force) {
this.inverse().remove(value);
} else {
Preconditions.checkArgument(!this.containsValue(value), "value already present: %s", value);
}
V oldValue = this.delegate.put(key, value);
this.updateInverseMap(key, containedKey, oldValue, value);
return oldValue;
}
private void updateInverseMap(K key, boolean containedKey, V oldValue, V newValue) {
if (containedKey) {
this.removeFromInverseMap(oldValue);
}
this.inverse.delegate.put(newValue, key);
}
@Override
public V remove(@Nullable Object key) {
return this.containsKey(key) ? (V)this.removeFromBothMaps(key) : null;
}
private V removeFromBothMaps(Object key) {
V oldValue = this.delegate.remove(key);
this.removeFromInverseMap(oldValue);
return oldValue;
}
private void removeFromInverseMap(V oldValue) {
this.inverse.delegate.remove(oldValue);
}
@Override
public void putAll(Map<? extends K, ? extends V> map) {
for (Map.Entry<K, V> entry : map.entrySet()) {
this.put(entry.getKey(), entry.getValue());
}
}
@Override
public void clear() {
this.delegate.clear();
this.inverse.delegate.clear();
}
@Override
public BiMap<V, K> inverse() {
return this.inverse;
}
@Override
public Set<K> keySet() {
KeySet result = this.keySet;
return result == null ? (this.keySet = new KeySet()) : result;
}
@Override
public Set<V> values() {
ValueSet result = this.valueSet;
return result == null ? (this.valueSet = new ValueSet()) : result;
}
@Override
public Set<Map.Entry<K, V>> entrySet() {
EntrySet result = this.entrySet;
return result == null ? (this.entrySet = new EntrySet()) : result;
}
private static class Inverse<K, V>
extends AbstractBiMap<K, V> {
@GwtIncompatible(value="Not needed in emulated source.")
private static final long serialVersionUID = 0L;
private Inverse(Map<K, V> backward, AbstractBiMap<V, K> forward) {
super(backward, forward);
}
@Override
K checkKey(K key) {
return this.inverse.checkValue(key);
}
@Override
V checkValue(V value) {
return this.inverse.checkKey(value);
}
@GwtIncompatible(value="java.io.ObjectOuputStream")
private void writeObject(ObjectOutputStream stream) throws IOException {
stream.defaultWriteObject();
stream.writeObject(this.inverse());
}
@GwtIncompatible(value="java.io.ObjectInputStream")
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
this.setInverse((AbstractBiMap)stream.readObject());
}
@GwtIncompatible(value="Not needed in the emulated source.")
Object readResolve() {
return this.inverse().inverse();
}
}
private class EntrySet
extends ForwardingSet<Map.Entry<K, V>> {
final Set<Map.Entry<K, V>> esDelegate;
private EntrySet() {
this.esDelegate = AbstractBiMap.this.delegate.entrySet();
}
@Override
protected Set<Map.Entry<K, V>> delegate() {
return this.esDelegate;
}
@Override
public void clear() {
AbstractBiMap.this.clear();
}
@Override
public boolean remove(Object object) {
if (!this.esDelegate.contains(object)) {
return false;
}
Map.Entry entry = (Map.Entry)object;
AbstractBiMap.this.inverse.delegate.remove(entry.getValue());
this.esDelegate.remove(entry);
return true;
}
@Override
public Iterator<Map.Entry<K, V>> iterator() {
final Iterator iterator = this.esDelegate.iterator();
return new Iterator<Map.Entry<K, V>>(){
Map.Entry<K, V> entry;
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public Map.Entry<K, V> next() {
this.entry = (Map.Entry)iterator.next();
final Map.Entry finalEntry = this.entry;
return new ForwardingMapEntry<K, V>(){
@Override
protected Map.Entry<K, V> delegate() {
return finalEntry;
}
@Override
public V setValue(V value) {
Preconditions.checkState(EntrySet.this.contains(this), "entry no longer in map");
if (Objects.equal(value, this.getValue())) {
return value;
}
Preconditions.checkArgument(!AbstractBiMap.this.containsValue(value), "value already present: %s", value);
Object oldValue = finalEntry.setValue(value);
Preconditions.checkState(Objects.equal(value, AbstractBiMap.this.get(this.getKey())), "entry no longer in map");
AbstractBiMap.this.updateInverseMap(this.getKey(), true, oldValue, value);
return oldValue;
}
};
}
@Override
public void remove() {
CollectPreconditions.checkRemove(this.entry != null);
Object value = this.entry.getValue();
iterator.remove();
AbstractBiMap.this.removeFromInverseMap(value);
}
};
}
@Override
public Object[] toArray() {
return this.standardToArray();
}
@Override
public <T> T[] toArray(T[] array) {
return this.standardToArray(array);
}
@Override
public boolean contains(Object o) {
return Maps.containsEntryImpl(this.delegate(), o);
}
@Override
public boolean containsAll(Collection<?> c) {
return this.standardContainsAll(c);
}
@Override
public boolean removeAll(Collection<?> c) {
return this.standardRemoveAll(c);
}
@Override
public boolean retainAll(Collection<?> c) {
return this.standardRetainAll(c);
}
}
private class ValueSet
extends ForwardingSet<V> {
final Set<V> valuesDelegate;
private ValueSet() {
this.valuesDelegate = AbstractBiMap.this.inverse.keySet();
}
@Override
protected Set<V> delegate() {
return this.valuesDelegate;
}
@Override
public Iterator<V> iterator() {
return Maps.valueIterator(AbstractBiMap.this.entrySet().iterator());
}
@Override
public Object[] toArray() {
return this.standardToArray();
}
@Override
public <T> T[] toArray(T[] array) {
return this.standardToArray(array);
}
@Override
public String toString() {
return this.standardToString();
}
}
private class KeySet
extends ForwardingSet<K> {
private KeySet() {
}
@Override
protected Set<K> delegate() {
return AbstractBiMap.this.delegate.keySet();
}
@Override
public void clear() {
AbstractBiMap.this.clear();
}
@Override
public boolean remove(Object key) {
if (!this.contains(key)) {
return false;
}
AbstractBiMap.this.removeFromBothMaps(key);
return true;
}
@Override
public boolean removeAll(Collection<?> keysToRemove) {
return this.standardRemoveAll(keysToRemove);
}
@Override
public boolean retainAll(Collection<?> keysToRetain) {
return this.standardRetainAll(keysToRetain);
}
@Override
public Iterator<K> iterator() {
return Maps.keyIterator(AbstractBiMap.this.entrySet().iterator());
}
}
}

View file

@ -0,0 +1,64 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Preconditions;
import com.google.common.collect.UnmodifiableListIterator;
import java.util.NoSuchElementException;
@GwtCompatible
abstract class AbstractIndexedListIterator<E>
extends UnmodifiableListIterator<E> {
private final int size;
private int position;
protected abstract E get(int var1);
protected AbstractIndexedListIterator(int size) {
this(size, 0);
}
protected AbstractIndexedListIterator(int size, int position) {
Preconditions.checkPositionIndex(position, size);
this.size = size;
this.position = position;
}
@Override
public final boolean hasNext() {
return this.position < this.size;
}
@Override
public final E next() {
if (!this.hasNext()) {
throw new NoSuchElementException();
}
return this.get(this.position++);
}
@Override
public final int nextIndex() {
return this.position;
}
@Override
public final boolean hasPrevious() {
return this.position > 0;
}
@Override
public final E previous() {
if (!this.hasPrevious()) {
throw new NoSuchElementException();
}
return this.get(--this.position);
}
@Override
public final int previousIndex() {
return this.position - 1;
}
}

View file

@ -0,0 +1,76 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Preconditions;
import com.google.common.collect.UnmodifiableIterator;
import java.util.NoSuchElementException;
@GwtCompatible
public abstract class AbstractIterator<T>
extends UnmodifiableIterator<T> {
private State state = State.NOT_READY;
private T next;
protected AbstractIterator() {
}
protected abstract T computeNext();
protected final T endOfData() {
this.state = State.DONE;
return null;
}
@Override
public final boolean hasNext() {
Preconditions.checkState(this.state != State.FAILED);
switch (this.state) {
case DONE: {
return false;
}
case READY: {
return true;
}
}
return this.tryToComputeNext();
}
private boolean tryToComputeNext() {
this.state = State.FAILED;
this.next = this.computeNext();
if (this.state != State.DONE) {
this.state = State.READY;
return true;
}
return false;
}
@Override
public final T next() {
if (!this.hasNext()) {
throw new NoSuchElementException();
}
this.state = State.NOT_READY;
T result = this.next;
this.next = null;
return result;
}
public final T peek() {
if (!this.hasNext()) {
throw new NoSuchElementException();
}
return this.next;
}
private static enum State {
READY,
NOT_READY,
DONE,
FAILED;
}
}

View file

@ -0,0 +1,62 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.AbstractMapBasedMultimap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ListMultimap;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
@GwtCompatible
abstract class AbstractListMultimap<K, V>
extends AbstractMapBasedMultimap<K, V>
implements ListMultimap<K, V> {
private static final long serialVersionUID = 6588350623831699109L;
protected AbstractListMultimap(Map<K, Collection<V>> map) {
super(map);
}
@Override
abstract List<V> createCollection();
@Override
List<V> createUnmodifiableEmptyCollection() {
return ImmutableList.of();
}
@Override
public List<V> get(@Nullable K key) {
return (List)super.get(key);
}
@Override
public List<V> removeAll(@Nullable Object key) {
return (List)super.removeAll(key);
}
@Override
public List<V> replaceValues(@Nullable K key, Iterable<? extends V> values) {
return (List)super.replaceValues(key, values);
}
@Override
public boolean put(@Nullable K key, @Nullable V value) {
return super.put(key, value);
}
@Override
public Map<K, Collection<V>> asMap() {
return super.asMap();
}
@Override
public boolean equals(@Nullable Object object) {
return super.equals(object);
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,237 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Preconditions;
import com.google.common.collect.AbstractMultiset;
import com.google.common.collect.CollectPreconditions;
import com.google.common.collect.Count;
import com.google.common.collect.Maps;
import com.google.common.collect.Multiset;
import com.google.common.collect.Multisets;
import com.google.common.primitives.Ints;
import java.io.InvalidObjectException;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
@GwtCompatible(emulated=true)
abstract class AbstractMapBasedMultiset<E>
extends AbstractMultiset<E>
implements Serializable {
private transient Map<E, Count> backingMap;
private transient long size;
@GwtIncompatible(value="not needed in emulated source.")
private static final long serialVersionUID = -2250766705698539974L;
protected AbstractMapBasedMultiset(Map<E, Count> backingMap) {
this.backingMap = Preconditions.checkNotNull(backingMap);
this.size = super.size();
}
void setBackingMap(Map<E, Count> backingMap) {
this.backingMap = backingMap;
}
@Override
public Set<Multiset.Entry<E>> entrySet() {
return super.entrySet();
}
@Override
Iterator<Multiset.Entry<E>> entryIterator() {
final Iterator<Map.Entry<E, Count>> backingEntries = this.backingMap.entrySet().iterator();
return new Iterator<Multiset.Entry<E>>(){
Map.Entry<E, Count> toRemove;
@Override
public boolean hasNext() {
return backingEntries.hasNext();
}
@Override
public Multiset.Entry<E> next() {
Map.Entry mapEntry;
this.toRemove = mapEntry = (Map.Entry)backingEntries.next();
return new Multisets.AbstractEntry<E>(){
@Override
public E getElement() {
return mapEntry.getKey();
}
@Override
public int getCount() {
Count frequency;
Count count = (Count)mapEntry.getValue();
if ((count == null || count.get() == 0) && (frequency = (Count)AbstractMapBasedMultiset.this.backingMap.get(this.getElement())) != null) {
return frequency.get();
}
return count == null ? 0 : count.get();
}
};
}
@Override
public void remove() {
CollectPreconditions.checkRemove(this.toRemove != null);
AbstractMapBasedMultiset.this.size -= this.toRemove.getValue().getAndSet(0);
backingEntries.remove();
this.toRemove = null;
}
};
}
@Override
public void clear() {
for (Count frequency : this.backingMap.values()) {
frequency.set(0);
}
this.backingMap.clear();
this.size = 0L;
}
@Override
int distinctElements() {
return this.backingMap.size();
}
@Override
public int size() {
return Ints.saturatedCast(this.size);
}
@Override
public Iterator<E> iterator() {
return new MapBasedMultisetIterator();
}
@Override
public int count(@Nullable Object element) {
Count frequency = Maps.safeGet(this.backingMap, element);
return frequency == null ? 0 : frequency.get();
}
@Override
public int add(@Nullable E element, int occurrences) {
int oldCount;
if (occurrences == 0) {
return this.count(element);
}
Preconditions.checkArgument(occurrences > 0, "occurrences cannot be negative: %s", occurrences);
Count frequency = this.backingMap.get(element);
if (frequency == null) {
oldCount = 0;
this.backingMap.put(element, new Count(occurrences));
} else {
oldCount = frequency.get();
long newCount = (long)oldCount + (long)occurrences;
Preconditions.checkArgument(newCount <= Integer.MAX_VALUE, "too many occurrences: %s", newCount);
frequency.getAndAdd(occurrences);
}
this.size += (long)occurrences;
return oldCount;
}
@Override
public int remove(@Nullable Object element, int occurrences) {
int numberRemoved;
if (occurrences == 0) {
return this.count(element);
}
Preconditions.checkArgument(occurrences > 0, "occurrences cannot be negative: %s", occurrences);
Count frequency = this.backingMap.get(element);
if (frequency == null) {
return 0;
}
int oldCount = frequency.get();
if (oldCount > occurrences) {
numberRemoved = occurrences;
} else {
numberRemoved = oldCount;
this.backingMap.remove(element);
}
frequency.addAndGet(-numberRemoved);
this.size -= (long)numberRemoved;
return oldCount;
}
@Override
public int setCount(@Nullable E element, int count) {
int oldCount;
CollectPreconditions.checkNonnegative(count, "count");
if (count == 0) {
Count existingCounter = this.backingMap.remove(element);
oldCount = AbstractMapBasedMultiset.getAndSet(existingCounter, count);
} else {
Count existingCounter = this.backingMap.get(element);
oldCount = AbstractMapBasedMultiset.getAndSet(existingCounter, count);
if (existingCounter == null) {
this.backingMap.put(element, new Count(count));
}
}
this.size += (long)(count - oldCount);
return oldCount;
}
private static int getAndSet(Count i, int count) {
if (i == null) {
return 0;
}
return i.getAndSet(count);
}
@GwtIncompatible(value="java.io.ObjectStreamException")
private void readObjectNoData() throws ObjectStreamException {
throw new InvalidObjectException("Stream data required");
}
private class MapBasedMultisetIterator
implements Iterator<E> {
final Iterator<Map.Entry<E, Count>> entryIterator;
Map.Entry<E, Count> currentEntry;
int occurrencesLeft;
boolean canRemove;
MapBasedMultisetIterator() {
this.entryIterator = AbstractMapBasedMultiset.this.backingMap.entrySet().iterator();
}
@Override
public boolean hasNext() {
return this.occurrencesLeft > 0 || this.entryIterator.hasNext();
}
@Override
public E next() {
if (this.occurrencesLeft == 0) {
this.currentEntry = this.entryIterator.next();
this.occurrencesLeft = this.currentEntry.getValue().get();
}
--this.occurrencesLeft;
this.canRemove = true;
return this.currentEntry.getKey();
}
@Override
public void remove() {
CollectPreconditions.checkRemove(this.canRemove);
int frequency = this.currentEntry.getValue().get();
if (frequency <= 0) {
throw new ConcurrentModificationException();
}
if (this.currentEntry.getValue().addAndGet(-1) == 0) {
this.entryIterator.remove();
}
AbstractMapBasedMultiset.this.size--;
this.canRemove = false;
}
}
}

View file

@ -0,0 +1,49 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Objects;
import java.util.Map;
import javax.annotation.Nullable;
@GwtCompatible
abstract class AbstractMapEntry<K, V>
implements Map.Entry<K, V> {
AbstractMapEntry() {
}
@Override
public abstract K getKey();
@Override
public abstract V getValue();
@Override
public V setValue(V value) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(@Nullable Object object) {
if (object instanceof Map.Entry) {
Map.Entry that = (Map.Entry)object;
return Objects.equal(this.getKey(), that.getKey()) && Objects.equal(this.getValue(), that.getValue());
}
return false;
}
@Override
public int hashCode() {
K k = this.getKey();
V v = this.getValue();
return (k == null ? 0 : k.hashCode()) ^ (v == null ? 0 : v.hashCode());
}
public String toString() {
String string = String.valueOf(String.valueOf(this.getKey()));
String string2 = String.valueOf(String.valueOf(this.getValue()));
return new StringBuilder(1 + string.length() + string2.length()).append(string).append("=").append(string2).toString();
}
}

View file

@ -0,0 +1,222 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterators;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.common.collect.Multiset;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.Sets;
import java.util.AbstractCollection;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
@GwtCompatible
abstract class AbstractMultimap<K, V>
implements Multimap<K, V> {
private transient Collection<Map.Entry<K, V>> entries;
private transient Set<K> keySet;
private transient Multiset<K> keys;
private transient Collection<V> values;
private transient Map<K, Collection<V>> asMap;
AbstractMultimap() {
}
@Override
public boolean isEmpty() {
return this.size() == 0;
}
@Override
public boolean containsValue(@Nullable Object value) {
for (Collection<V> collection : this.asMap().values()) {
if (!collection.contains(value)) continue;
return true;
}
return false;
}
@Override
public boolean containsEntry(@Nullable Object key, @Nullable Object value) {
Collection<V> collection = this.asMap().get(key);
return collection != null && collection.contains(value);
}
@Override
public boolean remove(@Nullable Object key, @Nullable Object value) {
Collection<V> collection = this.asMap().get(key);
return collection != null && collection.remove(value);
}
@Override
public boolean put(@Nullable K key, @Nullable V value) {
return this.get(key).add(value);
}
@Override
public boolean putAll(@Nullable K key, Iterable<? extends V> values) {
Preconditions.checkNotNull(values);
if (values instanceof Collection) {
Collection valueCollection = (Collection)values;
return !valueCollection.isEmpty() && this.get(key).addAll(valueCollection);
}
Iterator<V> valueItr = values.iterator();
return valueItr.hasNext() && Iterators.addAll(this.get(key), valueItr);
}
@Override
public boolean putAll(Multimap<? extends K, ? extends V> multimap) {
boolean changed = false;
for (Map.Entry<K, V> entry : multimap.entries()) {
changed |= this.put(entry.getKey(), entry.getValue());
}
return changed;
}
@Override
public Collection<V> replaceValues(@Nullable K key, Iterable<? extends V> values) {
Preconditions.checkNotNull(values);
Collection result = this.removeAll(key);
this.putAll(key, values);
return result;
}
@Override
public Collection<Map.Entry<K, V>> entries() {
Collection<Map.Entry<K, V>> result = this.entries;
return result == null ? (this.entries = this.createEntries()) : result;
}
Collection<Map.Entry<K, V>> createEntries() {
if (this instanceof SetMultimap) {
return new EntrySet();
}
return new Entries();
}
abstract Iterator<Map.Entry<K, V>> entryIterator();
@Override
public Set<K> keySet() {
Set<K> result = this.keySet;
return result == null ? (this.keySet = this.createKeySet()) : result;
}
Set<K> createKeySet() {
return new Maps.KeySet<K, Collection<V>>(this.asMap());
}
@Override
public Multiset<K> keys() {
Multiset<K> result = this.keys;
return result == null ? (this.keys = this.createKeys()) : result;
}
Multiset<K> createKeys() {
return new Multimaps.Keys(this);
}
@Override
public Collection<V> values() {
Collection<V> result = this.values;
return result == null ? (this.values = this.createValues()) : result;
}
Collection<V> createValues() {
return new Values();
}
Iterator<V> valueIterator() {
return Maps.valueIterator(this.entries().iterator());
}
@Override
public Map<K, Collection<V>> asMap() {
Map<K, Collection<Collection<V>>> result = this.asMap;
return result == null ? (this.asMap = this.createAsMap()) : result;
}
abstract Map<K, Collection<V>> createAsMap();
@Override
public boolean equals(@Nullable Object object) {
return Multimaps.equalsImpl(this, object);
}
@Override
public int hashCode() {
return this.asMap().hashCode();
}
public String toString() {
return this.asMap().toString();
}
class Values
extends AbstractCollection<V> {
Values() {
}
@Override
public Iterator<V> iterator() {
return AbstractMultimap.this.valueIterator();
}
@Override
public int size() {
return AbstractMultimap.this.size();
}
@Override
public boolean contains(@Nullable Object o) {
return AbstractMultimap.this.containsValue(o);
}
@Override
public void clear() {
AbstractMultimap.this.clear();
}
}
private class EntrySet
extends Entries
implements Set<Map.Entry<K, V>> {
private EntrySet() {
}
@Override
public int hashCode() {
return Sets.hashCodeImpl(this);
}
@Override
public boolean equals(@Nullable Object obj) {
return Sets.equalsImpl(this, obj);
}
}
private class Entries
extends Multimaps.Entries<K, V> {
private Entries() {
}
@Override
Multimap<K, V> multimap() {
return AbstractMultimap.this;
}
@Override
public Iterator<Map.Entry<K, V>> iterator() {
return AbstractMultimap.this.entryIterator();
}
}
}

View file

@ -0,0 +1,183 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Objects;
import com.google.common.collect.Iterators;
import com.google.common.collect.Multiset;
import com.google.common.collect.Multisets;
import java.util.AbstractCollection;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import javax.annotation.Nullable;
@GwtCompatible
abstract class AbstractMultiset<E>
extends AbstractCollection<E>
implements Multiset<E> {
private transient Set<E> elementSet;
private transient Set<Multiset.Entry<E>> entrySet;
AbstractMultiset() {
}
@Override
public int size() {
return Multisets.sizeImpl(this);
}
@Override
public boolean isEmpty() {
return this.entrySet().isEmpty();
}
@Override
public boolean contains(@Nullable Object element) {
return this.count(element) > 0;
}
@Override
public Iterator<E> iterator() {
return Multisets.iteratorImpl(this);
}
@Override
public int count(@Nullable Object element) {
for (Multiset.Entry<E> entry : this.entrySet()) {
if (!Objects.equal(entry.getElement(), element)) continue;
return entry.getCount();
}
return 0;
}
@Override
public boolean add(@Nullable E element) {
this.add(element, 1);
return true;
}
@Override
public int add(@Nullable E element, int occurrences) {
throw new UnsupportedOperationException();
}
@Override
public boolean remove(@Nullable Object element) {
return this.remove(element, 1) > 0;
}
@Override
public int remove(@Nullable Object element, int occurrences) {
throw new UnsupportedOperationException();
}
@Override
public int setCount(@Nullable E element, int count) {
return Multisets.setCountImpl(this, element, count);
}
@Override
public boolean setCount(@Nullable E element, int oldCount, int newCount) {
return Multisets.setCountImpl(this, element, oldCount, newCount);
}
@Override
public boolean addAll(Collection<? extends E> elementsToAdd) {
return Multisets.addAllImpl(this, elementsToAdd);
}
@Override
public boolean removeAll(Collection<?> elementsToRemove) {
return Multisets.removeAllImpl(this, elementsToRemove);
}
@Override
public boolean retainAll(Collection<?> elementsToRetain) {
return Multisets.retainAllImpl(this, elementsToRetain);
}
@Override
public void clear() {
Iterators.clear(this.entryIterator());
}
@Override
public Set<E> elementSet() {
Set<E> result = this.elementSet;
if (result == null) {
this.elementSet = result = this.createElementSet();
}
return result;
}
Set<E> createElementSet() {
return new ElementSet();
}
abstract Iterator<Multiset.Entry<E>> entryIterator();
abstract int distinctElements();
@Override
public Set<Multiset.Entry<E>> entrySet() {
Set<Multiset.Entry<Multiset.Entry<E>>> result = this.entrySet;
if (result == null) {
this.entrySet = result = this.createEntrySet();
}
return result;
}
Set<Multiset.Entry<E>> createEntrySet() {
return new EntrySet();
}
@Override
public boolean equals(@Nullable Object object) {
return Multisets.equalsImpl(this, object);
}
@Override
public int hashCode() {
return this.entrySet().hashCode();
}
@Override
public String toString() {
return this.entrySet().toString();
}
class EntrySet
extends Multisets.EntrySet<E> {
EntrySet() {
}
@Override
Multiset<E> multiset() {
return AbstractMultiset.this;
}
@Override
public Iterator<Multiset.Entry<E>> iterator() {
return AbstractMultiset.this.entryIterator();
}
@Override
public int size() {
return AbstractMultiset.this.distinctElements();
}
}
class ElementSet
extends Multisets.ElementSet<E> {
ElementSet() {
}
@Override
Multiset<E> multiset() {
return AbstractMultiset.this;
}
}
}

View file

@ -0,0 +1,187 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.collect.Iterators;
import com.google.common.collect.Maps;
import java.util.AbstractMap;
import java.util.Iterator;
import java.util.Map;
import java.util.NavigableMap;
import java.util.NavigableSet;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.SortedMap;
import javax.annotation.Nullable;
abstract class AbstractNavigableMap<K, V>
extends AbstractMap<K, V>
implements NavigableMap<K, V> {
AbstractNavigableMap() {
}
@Override
@Nullable
public abstract V get(@Nullable Object var1);
@Override
@Nullable
public Map.Entry<K, V> firstEntry() {
return Iterators.getNext(this.entryIterator(), null);
}
@Override
@Nullable
public Map.Entry<K, V> lastEntry() {
return Iterators.getNext(this.descendingEntryIterator(), null);
}
@Override
@Nullable
public Map.Entry<K, V> pollFirstEntry() {
return Iterators.pollNext(this.entryIterator());
}
@Override
@Nullable
public Map.Entry<K, V> pollLastEntry() {
return Iterators.pollNext(this.descendingEntryIterator());
}
@Override
public K firstKey() {
Map.Entry<K, V> entry = this.firstEntry();
if (entry == null) {
throw new NoSuchElementException();
}
return entry.getKey();
}
@Override
public K lastKey() {
Map.Entry<K, V> entry = this.lastEntry();
if (entry == null) {
throw new NoSuchElementException();
}
return entry.getKey();
}
@Override
@Nullable
public Map.Entry<K, V> lowerEntry(K key) {
return this.headMap(key, false).lastEntry();
}
@Override
@Nullable
public Map.Entry<K, V> floorEntry(K key) {
return this.headMap(key, true).lastEntry();
}
@Override
@Nullable
public Map.Entry<K, V> ceilingEntry(K key) {
return this.tailMap(key, true).firstEntry();
}
@Override
@Nullable
public Map.Entry<K, V> higherEntry(K key) {
return this.tailMap(key, false).firstEntry();
}
@Override
public K lowerKey(K key) {
return Maps.keyOrNull(this.lowerEntry(key));
}
@Override
public K floorKey(K key) {
return Maps.keyOrNull(this.floorEntry(key));
}
@Override
public K ceilingKey(K key) {
return Maps.keyOrNull(this.ceilingEntry(key));
}
@Override
public K higherKey(K key) {
return Maps.keyOrNull(this.higherEntry(key));
}
abstract Iterator<Map.Entry<K, V>> entryIterator();
abstract Iterator<Map.Entry<K, V>> descendingEntryIterator();
@Override
public SortedMap<K, V> subMap(K fromKey, K toKey) {
return this.subMap(fromKey, true, toKey, false);
}
@Override
public SortedMap<K, V> headMap(K toKey) {
return this.headMap(toKey, false);
}
@Override
public SortedMap<K, V> tailMap(K fromKey) {
return this.tailMap(fromKey, true);
}
@Override
public NavigableSet<K> navigableKeySet() {
return new Maps.NavigableKeySet(this);
}
@Override
public Set<K> keySet() {
return this.navigableKeySet();
}
@Override
public abstract int size();
@Override
public Set<Map.Entry<K, V>> entrySet() {
return new Maps.EntrySet<K, V>(){
@Override
Map<K, V> map() {
return AbstractNavigableMap.this;
}
@Override
public Iterator<Map.Entry<K, V>> iterator() {
return AbstractNavigableMap.this.entryIterator();
}
};
}
@Override
public NavigableSet<K> descendingKeySet() {
return this.descendingMap().navigableKeySet();
}
@Override
public NavigableMap<K, V> descendingMap() {
return new DescendingMap();
}
private final class DescendingMap
extends Maps.DescendingMap<K, V> {
private DescendingMap() {
}
@Override
NavigableMap<K, V> forward() {
return AbstractNavigableMap.this;
}
@Override
Iterator<Map.Entry<K, V>> entryIterator() {
return AbstractNavigableMap.this.descendingEntryIterator();
}
}
}

View file

@ -0,0 +1,90 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.collect.Range;
import com.google.common.collect.RangeSet;
import javax.annotation.Nullable;
abstract class AbstractRangeSet<C extends Comparable>
implements RangeSet<C> {
AbstractRangeSet() {
}
@Override
public boolean contains(C value) {
return this.rangeContaining(value) != null;
}
@Override
public abstract Range<C> rangeContaining(C var1);
@Override
public boolean isEmpty() {
return this.asRanges().isEmpty();
}
@Override
public void add(Range<C> range) {
throw new UnsupportedOperationException();
}
@Override
public void remove(Range<C> range) {
throw new UnsupportedOperationException();
}
@Override
public void clear() {
this.remove(Range.all());
}
@Override
public boolean enclosesAll(RangeSet<C> other) {
for (Range<C> range : other.asRanges()) {
if (this.encloses(range)) continue;
return false;
}
return true;
}
@Override
public void addAll(RangeSet<C> other) {
for (Range<C> range : other.asRanges()) {
this.add(range);
}
}
@Override
public void removeAll(RangeSet<C> other) {
for (Range<C> range : other.asRanges()) {
this.remove(range);
}
}
@Override
public abstract boolean encloses(Range<C> var1);
@Override
public boolean equals(@Nullable Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof RangeSet) {
RangeSet other = (RangeSet)obj;
return this.asRanges().equals(other.asRanges());
}
return false;
}
@Override
public final int hashCode() {
return this.asRanges().hashCode();
}
@Override
public final String toString() {
return this.asRanges().toString();
}
}

View file

@ -0,0 +1,43 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.UnmodifiableIterator;
import java.util.NoSuchElementException;
import javax.annotation.Nullable;
@GwtCompatible
public abstract class AbstractSequentialIterator<T>
extends UnmodifiableIterator<T> {
private T nextOrNull;
protected AbstractSequentialIterator(@Nullable T firstOrNull) {
this.nextOrNull = firstOrNull;
}
protected abstract T computeNext(T var1);
@Override
public final boolean hasNext() {
return this.nextOrNull != null;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
@Override
public final T next() {
if (!this.hasNext()) {
throw new NoSuchElementException();
}
try {
T t = this.nextOrNull;
return t;
}
finally {
this.nextOrNull = this.computeNext(this.nextOrNull);
}
}
}

View file

@ -0,0 +1,67 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.AbstractMapBasedMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.SetMultimap;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
@GwtCompatible
abstract class AbstractSetMultimap<K, V>
extends AbstractMapBasedMultimap<K, V>
implements SetMultimap<K, V> {
private static final long serialVersionUID = 7431625294878419160L;
protected AbstractSetMultimap(Map<K, Collection<V>> map) {
super(map);
}
@Override
abstract Set<V> createCollection();
@Override
Set<V> createUnmodifiableEmptyCollection() {
return ImmutableSet.of();
}
@Override
public Set<V> get(@Nullable K key) {
return (Set)super.get(key);
}
@Override
public Set<Map.Entry<K, V>> entries() {
return (Set)super.entries();
}
@Override
public Set<V> removeAll(@Nullable Object key) {
return (Set)super.removeAll(key);
}
@Override
public Set<V> replaceValues(@Nullable K key, Iterable<? extends V> values) {
return (Set)super.replaceValues(key, values);
}
@Override
public Map<K, Collection<V>> asMap() {
return super.asMap();
}
@Override
public boolean put(@Nullable K key, @Nullable V value) {
return super.put(key, value);
}
@Override
public boolean equals(@Nullable Object object) {
return super.equals(object);
}
}

View file

@ -0,0 +1,33 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.AbstractSortedSetMultimap;
import java.util.Collection;
import java.util.SortedMap;
import java.util.SortedSet;
@GwtCompatible
abstract class AbstractSortedKeySortedSetMultimap<K, V>
extends AbstractSortedSetMultimap<K, V> {
AbstractSortedKeySortedSetMultimap(SortedMap<K, Collection<V>> map) {
super(map);
}
@Override
public SortedMap<K, Collection<V>> asMap() {
return (SortedMap)super.asMap();
}
@Override
SortedMap<K, Collection<V>> backingMap() {
return (SortedMap)super.backingMap();
}
@Override
public SortedSet<K> keySet() {
return (SortedSet)super.keySet();
}
}

View file

@ -0,0 +1,127 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Preconditions;
import com.google.common.collect.AbstractMultiset;
import com.google.common.collect.BoundType;
import com.google.common.collect.DescendingMultiset;
import com.google.common.collect.GwtTransient;
import com.google.common.collect.Multiset;
import com.google.common.collect.Multisets;
import com.google.common.collect.Ordering;
import com.google.common.collect.SortedMultiset;
import com.google.common.collect.SortedMultisets;
import java.util.Comparator;
import java.util.Iterator;
import java.util.NavigableSet;
import javax.annotation.Nullable;
@GwtCompatible(emulated=true)
abstract class AbstractSortedMultiset<E>
extends AbstractMultiset<E>
implements SortedMultiset<E> {
@GwtTransient
final Comparator<? super E> comparator;
private transient SortedMultiset<E> descendingMultiset;
AbstractSortedMultiset() {
this(Ordering.natural());
}
AbstractSortedMultiset(Comparator<? super E> comparator) {
this.comparator = Preconditions.checkNotNull(comparator);
}
@Override
public NavigableSet<E> elementSet() {
return (NavigableSet)super.elementSet();
}
@Override
NavigableSet<E> createElementSet() {
return new SortedMultisets.NavigableElementSet(this);
}
@Override
public Comparator<? super E> comparator() {
return this.comparator;
}
@Override
public Multiset.Entry<E> firstEntry() {
Iterator entryIterator = this.entryIterator();
return entryIterator.hasNext() ? entryIterator.next() : null;
}
@Override
public Multiset.Entry<E> lastEntry() {
Iterator<Multiset.Entry<E>> entryIterator = this.descendingEntryIterator();
return entryIterator.hasNext() ? entryIterator.next() : null;
}
@Override
public Multiset.Entry<E> pollFirstEntry() {
Iterator entryIterator = this.entryIterator();
if (entryIterator.hasNext()) {
Multiset.Entry result = entryIterator.next();
result = Multisets.immutableEntry(result.getElement(), result.getCount());
entryIterator.remove();
return result;
}
return null;
}
@Override
public Multiset.Entry<E> pollLastEntry() {
Iterator<Multiset.Entry<E>> entryIterator = this.descendingEntryIterator();
if (entryIterator.hasNext()) {
Multiset.Entry<E> result = entryIterator.next();
result = Multisets.immutableEntry(result.getElement(), result.getCount());
entryIterator.remove();
return result;
}
return null;
}
@Override
public SortedMultiset<E> subMultiset(@Nullable E fromElement, BoundType fromBoundType, @Nullable E toElement, BoundType toBoundType) {
Preconditions.checkNotNull(fromBoundType);
Preconditions.checkNotNull(toBoundType);
return this.tailMultiset(fromElement, fromBoundType).headMultiset(toElement, toBoundType);
}
abstract Iterator<Multiset.Entry<E>> descendingEntryIterator();
Iterator<E> descendingIterator() {
return Multisets.iteratorImpl(this.descendingMultiset());
}
@Override
public SortedMultiset<E> descendingMultiset() {
SortedMultiset<E> result = this.descendingMultiset;
return result == null ? (this.descendingMultiset = this.createDescendingMultiset()) : result;
}
SortedMultiset<E> createDescendingMultiset() {
return new DescendingMultiset<E>(){
@Override
SortedMultiset<E> forwardMultiset() {
return AbstractSortedMultiset.this;
}
@Override
Iterator<Multiset.Entry<E>> entryIterator() {
return AbstractSortedMultiset.this.descendingEntryIterator();
}
@Override
public Iterator<E> iterator() {
return AbstractSortedMultiset.this.descendingIterator();
}
};
}
}

View file

@ -0,0 +1,63 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.AbstractSetMultimap;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.SortedSetMultimap;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;
import java.util.SortedSet;
import javax.annotation.Nullable;
@GwtCompatible
abstract class AbstractSortedSetMultimap<K, V>
extends AbstractSetMultimap<K, V>
implements SortedSetMultimap<K, V> {
private static final long serialVersionUID = 430848587173315748L;
protected AbstractSortedSetMultimap(Map<K, Collection<V>> map) {
super(map);
}
@Override
abstract SortedSet<V> createCollection();
@Override
SortedSet<V> createUnmodifiableEmptyCollection() {
Comparator comparator = this.valueComparator();
if (comparator == null) {
return Collections.unmodifiableSortedSet(this.createCollection());
}
return ImmutableSortedSet.emptySet(this.valueComparator());
}
@Override
public SortedSet<V> get(@Nullable K key) {
return (SortedSet)super.get((Object)key);
}
@Override
public SortedSet<V> removeAll(@Nullable Object key) {
return (SortedSet)super.removeAll(key);
}
@Override
public SortedSet<V> replaceValues(@Nullable K key, Iterable<? extends V> values) {
return (SortedSet)super.replaceValues((Object)key, (Iterable)values);
}
@Override
public Map<K, Collection<V>> asMap() {
return super.asMap();
}
@Override
public Collection<V> values() {
return super.values();
}
}

View file

@ -0,0 +1,211 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.Collections2;
import com.google.common.collect.Iterators;
import com.google.common.collect.Maps;
import com.google.common.collect.Table;
import com.google.common.collect.Tables;
import com.google.common.collect.TransformedIterator;
import java.util.AbstractCollection;
import java.util.AbstractSet;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
@GwtCompatible
abstract class AbstractTable<R, C, V>
implements Table<R, C, V> {
private transient Set<Table.Cell<R, C, V>> cellSet;
private transient Collection<V> values;
AbstractTable() {
}
@Override
public boolean containsRow(@Nullable Object rowKey) {
return Maps.safeContainsKey(this.rowMap(), rowKey);
}
@Override
public boolean containsColumn(@Nullable Object columnKey) {
return Maps.safeContainsKey(this.columnMap(), columnKey);
}
@Override
public Set<R> rowKeySet() {
return this.rowMap().keySet();
}
@Override
public Set<C> columnKeySet() {
return this.columnMap().keySet();
}
@Override
public boolean containsValue(@Nullable Object value) {
for (Map row : this.rowMap().values()) {
if (!row.containsValue(value)) continue;
return true;
}
return false;
}
@Override
public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) {
Map row = Maps.safeGet(this.rowMap(), rowKey);
return row != null && Maps.safeContainsKey(row, columnKey);
}
@Override
public V get(@Nullable Object rowKey, @Nullable Object columnKey) {
Map row = Maps.safeGet(this.rowMap(), rowKey);
return row == null ? null : (V)Maps.safeGet(row, columnKey);
}
@Override
public boolean isEmpty() {
return this.size() == 0;
}
@Override
public void clear() {
Iterators.clear(this.cellSet().iterator());
}
@Override
public V remove(@Nullable Object rowKey, @Nullable Object columnKey) {
Map row = Maps.safeGet(this.rowMap(), rowKey);
return row == null ? null : (V)Maps.safeRemove(row, columnKey);
}
@Override
public V put(R rowKey, C columnKey, V value) {
return this.row(rowKey).put(columnKey, value);
}
@Override
public void putAll(Table<? extends R, ? extends C, ? extends V> table) {
for (Table.Cell<R, C, V> cell : table.cellSet()) {
this.put(cell.getRowKey(), cell.getColumnKey(), cell.getValue());
}
}
@Override
public Set<Table.Cell<R, C, V>> cellSet() {
Set<Table.Cell<R, C, V>> result = this.cellSet;
return result == null ? (this.cellSet = this.createCellSet()) : result;
}
Set<Table.Cell<R, C, V>> createCellSet() {
return new CellSet();
}
abstract Iterator<Table.Cell<R, C, V>> cellIterator();
@Override
public Collection<V> values() {
Collection<V> result = this.values;
return result == null ? (this.values = this.createValues()) : result;
}
Collection<V> createValues() {
return new Values();
}
Iterator<V> valuesIterator() {
return new TransformedIterator<Table.Cell<R, C, V>, V>(this.cellSet().iterator()){
@Override
V transform(Table.Cell<R, C, V> cell) {
return cell.getValue();
}
};
}
@Override
public boolean equals(@Nullable Object obj) {
return Tables.equalsImpl(this, obj);
}
@Override
public int hashCode() {
return this.cellSet().hashCode();
}
public String toString() {
return this.rowMap().toString();
}
class Values
extends AbstractCollection<V> {
Values() {
}
@Override
public Iterator<V> iterator() {
return AbstractTable.this.valuesIterator();
}
@Override
public boolean contains(Object o) {
return AbstractTable.this.containsValue(o);
}
@Override
public void clear() {
AbstractTable.this.clear();
}
@Override
public int size() {
return AbstractTable.this.size();
}
}
class CellSet
extends AbstractSet<Table.Cell<R, C, V>> {
CellSet() {
}
@Override
public boolean contains(Object o) {
if (o instanceof Table.Cell) {
Table.Cell cell = (Table.Cell)o;
Map row = Maps.safeGet(AbstractTable.this.rowMap(), cell.getRowKey());
return row != null && Collections2.safeContains(row.entrySet(), Maps.immutableEntry(cell.getColumnKey(), cell.getValue()));
}
return false;
}
@Override
public boolean remove(@Nullable Object o) {
if (o instanceof Table.Cell) {
Table.Cell cell = (Table.Cell)o;
Map row = Maps.safeGet(AbstractTable.this.rowMap(), cell.getRowKey());
return row != null && Collections2.safeRemove(row.entrySet(), Maps.immutableEntry(cell.getColumnKey(), cell.getValue()));
}
return false;
}
@Override
public void clear() {
AbstractTable.this.clear();
}
@Override
public Iterator<Table.Cell<R, C, V>> iterator() {
return AbstractTable.this.cellIterator();
}
@Override
public int size() {
return AbstractTable.this.size();
}
}
}

View file

@ -0,0 +1,51 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
import java.io.Serializable;
import java.util.List;
import javax.annotation.Nullable;
@GwtCompatible(serializable=true)
final class AllEqualOrdering
extends Ordering<Object>
implements Serializable {
static final AllEqualOrdering INSTANCE = new AllEqualOrdering();
private static final long serialVersionUID = 0L;
AllEqualOrdering() {
}
@Override
public int compare(@Nullable Object left, @Nullable Object right) {
return 0;
}
@Override
public <E> List<E> sortedCopy(Iterable<E> iterable) {
return Lists.newArrayList(iterable);
}
@Override
public <E> ImmutableList<E> immutableSortedCopy(Iterable<E> iterable) {
return ImmutableList.copyOf(iterable);
}
@Override
public <S> Ordering<S> reverse() {
return this;
}
private Object readResolve() {
return INSTANCE;
}
public String toString() {
return "Ordering.allEqual()";
}
}

View file

@ -0,0 +1,87 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.AbstractListMultimap;
import com.google.common.collect.CollectPreconditions;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Serialization;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
@GwtCompatible(serializable=true, emulated=true)
public final class ArrayListMultimap<K, V>
extends AbstractListMultimap<K, V> {
private static final int DEFAULT_VALUES_PER_KEY = 3;
@VisibleForTesting
transient int expectedValuesPerKey;
@GwtIncompatible(value="Not needed in emulated source.")
private static final long serialVersionUID = 0L;
public static <K, V> ArrayListMultimap<K, V> create() {
return new ArrayListMultimap<K, V>();
}
public static <K, V> ArrayListMultimap<K, V> create(int expectedKeys, int expectedValuesPerKey) {
return new ArrayListMultimap<K, V>(expectedKeys, expectedValuesPerKey);
}
public static <K, V> ArrayListMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) {
return new ArrayListMultimap<K, V>(multimap);
}
private ArrayListMultimap() {
super(new HashMap());
this.expectedValuesPerKey = 3;
}
private ArrayListMultimap(int expectedKeys, int expectedValuesPerKey) {
super(Maps.newHashMapWithExpectedSize(expectedKeys));
CollectPreconditions.checkNonnegative(expectedValuesPerKey, "expectedValuesPerKey");
this.expectedValuesPerKey = expectedValuesPerKey;
}
private ArrayListMultimap(Multimap<? extends K, ? extends V> multimap) {
this(multimap.keySet().size(), multimap instanceof ArrayListMultimap ? ((ArrayListMultimap)multimap).expectedValuesPerKey : 3);
this.putAll((Multimap)multimap);
}
@Override
List<V> createCollection() {
return new ArrayList(this.expectedValuesPerKey);
}
public void trimToSize() {
for (Collection collection : this.backingMap().values()) {
ArrayList arrayList = (ArrayList)collection;
arrayList.trimToSize();
}
}
@GwtIncompatible(value="java.io.ObjectOutputStream")
private void writeObject(ObjectOutputStream stream) throws IOException {
stream.defaultWriteObject();
stream.writeInt(this.expectedValuesPerKey);
Serialization.writeMultimap(this, stream);
}
@GwtIncompatible(value="java.io.ObjectOutputStream")
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
this.expectedValuesPerKey = stream.readInt();
int distinctKeys = Serialization.readCount(stream);
HashMap map = Maps.newHashMapWithExpectedSize(distinctKeys);
this.setMap(map);
Serialization.populateMultimap(this, stream, distinctKeys);
}
}

View file

@ -0,0 +1,503 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.collect.AbstractIndexedListIterator;
import com.google.common.collect.AbstractMapEntry;
import com.google.common.collect.AbstractTable;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.Table;
import com.google.common.collect.Tables;
import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
@Beta
@GwtCompatible(emulated=true)
public final class ArrayTable<R, C, V>
extends AbstractTable<R, C, V>
implements Serializable {
private final ImmutableList<R> rowList;
private final ImmutableList<C> columnList;
private final ImmutableMap<R, Integer> rowKeyToIndex;
private final ImmutableMap<C, Integer> columnKeyToIndex;
private final V[][] array;
private transient ColumnMap columnMap;
private transient RowMap rowMap;
private static final long serialVersionUID = 0L;
public static <R, C, V> ArrayTable<R, C, V> create(Iterable<? extends R> rowKeys, Iterable<? extends C> columnKeys) {
return new ArrayTable<R, C, V>(rowKeys, columnKeys);
}
public static <R, C, V> ArrayTable<R, C, V> create(Table<R, C, V> table) {
return table instanceof ArrayTable ? new ArrayTable<R, C, V>((ArrayTable)table) : new ArrayTable<R, C, V>(table);
}
private ArrayTable(Iterable<? extends R> rowKeys, Iterable<? extends C> columnKeys) {
this.rowList = ImmutableList.copyOf(rowKeys);
this.columnList = ImmutableList.copyOf(columnKeys);
Preconditions.checkArgument(!this.rowList.isEmpty());
Preconditions.checkArgument(!this.columnList.isEmpty());
this.rowKeyToIndex = ArrayTable.index(this.rowList);
this.columnKeyToIndex = ArrayTable.index(this.columnList);
Object[][] tmpArray = new Object[this.rowList.size()][this.columnList.size()];
this.array = tmpArray;
this.eraseAll();
}
private static <E> ImmutableMap<E, Integer> index(List<E> list) {
ImmutableMap.Builder<E, Integer> columnBuilder = ImmutableMap.builder();
for (int i = 0; i < list.size(); ++i) {
columnBuilder.put(list.get(i), i);
}
return columnBuilder.build();
}
private ArrayTable(Table<R, C, V> table) {
this(table.rowKeySet(), table.columnKeySet());
this.putAll(table);
}
private ArrayTable(ArrayTable<R, C, V> table) {
this.rowList = table.rowList;
this.columnList = table.columnList;
this.rowKeyToIndex = table.rowKeyToIndex;
this.columnKeyToIndex = table.columnKeyToIndex;
Object[][] copy = new Object[this.rowList.size()][this.columnList.size()];
this.array = copy;
this.eraseAll();
for (int i = 0; i < this.rowList.size(); ++i) {
System.arraycopy(table.array[i], 0, copy[i], 0, table.array[i].length);
}
}
public ImmutableList<R> rowKeyList() {
return this.rowList;
}
public ImmutableList<C> columnKeyList() {
return this.columnList;
}
public V at(int rowIndex, int columnIndex) {
Preconditions.checkElementIndex(rowIndex, this.rowList.size());
Preconditions.checkElementIndex(columnIndex, this.columnList.size());
return this.array[rowIndex][columnIndex];
}
public V set(int rowIndex, int columnIndex, @Nullable V value) {
Preconditions.checkElementIndex(rowIndex, this.rowList.size());
Preconditions.checkElementIndex(columnIndex, this.columnList.size());
V oldValue = this.array[rowIndex][columnIndex];
this.array[rowIndex][columnIndex] = value;
return oldValue;
}
@GwtIncompatible(value="reflection")
public V[][] toArray(Class<V> valueClass) {
Object[][] copy = (Object[][])Array.newInstance(valueClass, this.rowList.size(), this.columnList.size());
for (int i = 0; i < this.rowList.size(); ++i) {
System.arraycopy(this.array[i], 0, copy[i], 0, this.array[i].length);
}
return copy;
}
@Override
@Deprecated
public void clear() {
throw new UnsupportedOperationException();
}
public void eraseAll() {
for (Object[] objectArray : this.array) {
Arrays.fill(objectArray, null);
}
}
@Override
public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) {
return this.containsRow(rowKey) && this.containsColumn(columnKey);
}
@Override
public boolean containsColumn(@Nullable Object columnKey) {
return this.columnKeyToIndex.containsKey(columnKey);
}
@Override
public boolean containsRow(@Nullable Object rowKey) {
return this.rowKeyToIndex.containsKey(rowKey);
}
@Override
public boolean containsValue(@Nullable Object value) {
V[][] arr$ = this.array;
int len$ = arr$.length;
for (int i$ = 0; i$ < len$; ++i$) {
V[] row;
for (V element : row = arr$[i$]) {
if (!Objects.equal(value, element)) continue;
return true;
}
}
return false;
}
@Override
public V get(@Nullable Object rowKey, @Nullable Object columnKey) {
Integer rowIndex = this.rowKeyToIndex.get(rowKey);
Integer columnIndex = this.columnKeyToIndex.get(columnKey);
return rowIndex == null || columnIndex == null ? null : (V)this.at(rowIndex, columnIndex);
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public V put(R rowKey, C columnKey, @Nullable V value) {
Preconditions.checkNotNull(rowKey);
Preconditions.checkNotNull(columnKey);
Integer rowIndex = this.rowKeyToIndex.get(rowKey);
Preconditions.checkArgument(rowIndex != null, "Row %s not in %s", rowKey, this.rowList);
Integer columnIndex = this.columnKeyToIndex.get(columnKey);
Preconditions.checkArgument(columnIndex != null, "Column %s not in %s", columnKey, this.columnList);
return this.set(rowIndex, columnIndex, value);
}
@Override
public void putAll(Table<? extends R, ? extends C, ? extends V> table) {
super.putAll(table);
}
@Override
@Deprecated
public V remove(Object rowKey, Object columnKey) {
throw new UnsupportedOperationException();
}
public V erase(@Nullable Object rowKey, @Nullable Object columnKey) {
Integer rowIndex = this.rowKeyToIndex.get(rowKey);
Integer columnIndex = this.columnKeyToIndex.get(columnKey);
if (rowIndex == null || columnIndex == null) {
return null;
}
return this.set(rowIndex, columnIndex, null);
}
@Override
public int size() {
return this.rowList.size() * this.columnList.size();
}
@Override
public Set<Table.Cell<R, C, V>> cellSet() {
return super.cellSet();
}
@Override
Iterator<Table.Cell<R, C, V>> cellIterator() {
return new AbstractIndexedListIterator<Table.Cell<R, C, V>>(this.size()){
@Override
protected Table.Cell<R, C, V> get(final int index) {
return new Tables.AbstractCell<R, C, V>(){
final int rowIndex;
final int columnIndex;
{
this.rowIndex = index / ArrayTable.this.columnList.size();
this.columnIndex = index % ArrayTable.this.columnList.size();
}
@Override
public R getRowKey() {
return ArrayTable.this.rowList.get(this.rowIndex);
}
@Override
public C getColumnKey() {
return ArrayTable.this.columnList.get(this.columnIndex);
}
@Override
public V getValue() {
return ArrayTable.this.at(this.rowIndex, this.columnIndex);
}
};
}
};
}
@Override
public Map<R, V> column(C columnKey) {
Preconditions.checkNotNull(columnKey);
Integer columnIndex = this.columnKeyToIndex.get(columnKey);
return columnIndex == null ? ImmutableMap.of() : new Column(columnIndex);
}
@Override
public ImmutableSet<C> columnKeySet() {
return this.columnKeyToIndex.keySet();
}
@Override
public Map<C, Map<R, V>> columnMap() {
ColumnMap map = this.columnMap;
return map == null ? (this.columnMap = new ColumnMap()) : map;
}
@Override
public Map<C, V> row(R rowKey) {
Preconditions.checkNotNull(rowKey);
Integer rowIndex = this.rowKeyToIndex.get(rowKey);
return rowIndex == null ? ImmutableMap.of() : new Row(rowIndex);
}
@Override
public ImmutableSet<R> rowKeySet() {
return this.rowKeyToIndex.keySet();
}
@Override
public Map<R, Map<C, V>> rowMap() {
RowMap map = this.rowMap;
return map == null ? (this.rowMap = new RowMap()) : map;
}
@Override
public Collection<V> values() {
return super.values();
}
private class RowMap
extends ArrayMap<R, Map<C, V>> {
private RowMap() {
super(ArrayTable.this.rowKeyToIndex);
}
@Override
String getKeyRole() {
return "Row";
}
@Override
Map<C, V> getValue(int index) {
return new Row(index);
}
@Override
Map<C, V> setValue(int index, Map<C, V> newValue) {
throw new UnsupportedOperationException();
}
@Override
public Map<C, V> put(R key, Map<C, V> value) {
throw new UnsupportedOperationException();
}
}
private class Row
extends ArrayMap<C, V> {
final int rowIndex;
Row(int rowIndex) {
super(ArrayTable.this.columnKeyToIndex);
this.rowIndex = rowIndex;
}
@Override
String getKeyRole() {
return "Column";
}
@Override
V getValue(int index) {
return ArrayTable.this.at(this.rowIndex, index);
}
@Override
V setValue(int index, V newValue) {
return ArrayTable.this.set(this.rowIndex, index, newValue);
}
}
private class ColumnMap
extends ArrayMap<C, Map<R, V>> {
private ColumnMap() {
super(ArrayTable.this.columnKeyToIndex);
}
@Override
String getKeyRole() {
return "Column";
}
@Override
Map<R, V> getValue(int index) {
return new Column(index);
}
@Override
Map<R, V> setValue(int index, Map<R, V> newValue) {
throw new UnsupportedOperationException();
}
@Override
public Map<R, V> put(C key, Map<R, V> value) {
throw new UnsupportedOperationException();
}
}
private class Column
extends ArrayMap<R, V> {
final int columnIndex;
Column(int columnIndex) {
super(ArrayTable.this.rowKeyToIndex);
this.columnIndex = columnIndex;
}
@Override
String getKeyRole() {
return "Row";
}
@Override
V getValue(int index) {
return ArrayTable.this.at(index, this.columnIndex);
}
@Override
V setValue(int index, V newValue) {
return ArrayTable.this.set(index, this.columnIndex, newValue);
}
}
private static abstract class ArrayMap<K, V>
extends Maps.ImprovedAbstractMap<K, V> {
private final ImmutableMap<K, Integer> keyIndex;
private ArrayMap(ImmutableMap<K, Integer> keyIndex) {
this.keyIndex = keyIndex;
}
@Override
public Set<K> keySet() {
return this.keyIndex.keySet();
}
K getKey(int index) {
return (K)((ImmutableCollection)((Object)this.keyIndex.keySet())).asList().get(index);
}
abstract String getKeyRole();
@Nullable
abstract V getValue(int var1);
@Nullable
abstract V setValue(int var1, V var2);
@Override
public int size() {
return this.keyIndex.size();
}
@Override
public boolean isEmpty() {
return this.keyIndex.isEmpty();
}
@Override
protected Set<Map.Entry<K, V>> createEntrySet() {
return new Maps.EntrySet<K, V>(){
@Override
Map<K, V> map() {
return ArrayMap.this;
}
@Override
public Iterator<Map.Entry<K, V>> iterator() {
return new AbstractIndexedListIterator<Map.Entry<K, V>>(this.size()){
@Override
protected Map.Entry<K, V> get(final int index) {
return new AbstractMapEntry<K, V>(){
@Override
public K getKey() {
return ArrayMap.this.getKey(index);
}
@Override
public V getValue() {
return ArrayMap.this.getValue(index);
}
@Override
public V setValue(V value) {
return ArrayMap.this.setValue(index, value);
}
};
}
};
}
};
}
@Override
public boolean containsKey(@Nullable Object key) {
return this.keyIndex.containsKey(key);
}
@Override
public V get(@Nullable Object key) {
Integer index = this.keyIndex.get(key);
if (index == null) {
return null;
}
return this.getValue(index);
}
@Override
public V put(K key, V value) {
Integer index = this.keyIndex.get(key);
if (index == null) {
String string = String.valueOf(String.valueOf(this.getKeyRole()));
String string2 = String.valueOf(String.valueOf(key));
String string3 = String.valueOf(String.valueOf(this.keyIndex.keySet()));
throw new IllegalArgumentException(new StringBuilder(9 + string.length() + string2.length() + string3.length()).append(string).append(" ").append(string2).append(" not in ").append(string3).toString());
}
return this.setValue(index, value);
}
@Override
public V remove(Object key) {
throw new UnsupportedOperationException();
}
@Override
public void clear() {
throw new UnsupportedOperationException();
}
}
}

View file

@ -0,0 +1,26 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
@GwtCompatible
public interface BiMap<K, V>
extends Map<K, V> {
@Override
public V put(@Nullable K var1, @Nullable V var2);
public V forcePut(@Nullable K var1, @Nullable V var2);
@Override
public void putAll(Map<? extends K, ? extends V> var1);
@Override
public Set<V> values();
public BiMap<V, K> inverse();
}

View file

@ -0,0 +1,174 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.AbstractIterator;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.PeekingIterator;
import com.google.common.collect.TreeTraverser;
import com.google.common.collect.UnmodifiableIterator;
import java.util.ArrayDeque;
import java.util.BitSet;
import java.util.Deque;
import java.util.Iterator;
@Beta
@GwtCompatible(emulated=true)
public abstract class BinaryTreeTraverser<T>
extends TreeTraverser<T> {
public abstract Optional<T> leftChild(T var1);
public abstract Optional<T> rightChild(T var1);
@Override
public final Iterable<T> children(final T root) {
Preconditions.checkNotNull(root);
return new FluentIterable<T>(){
@Override
public Iterator<T> iterator() {
return new AbstractIterator<T>(){
boolean doneLeft;
boolean doneRight;
@Override
protected T computeNext() {
if (!this.doneLeft) {
this.doneLeft = true;
Optional<Object> left = BinaryTreeTraverser.this.leftChild(root);
if (left.isPresent()) {
return left.get();
}
}
if (!this.doneRight) {
this.doneRight = true;
Optional<Object> right = BinaryTreeTraverser.this.rightChild(root);
if (right.isPresent()) {
return right.get();
}
}
return this.endOfData();
}
};
}
};
}
@Override
UnmodifiableIterator<T> preOrderIterator(T root) {
return new PreOrderIterator(root);
}
@Override
UnmodifiableIterator<T> postOrderIterator(T root) {
return new PostOrderIterator(root);
}
public final FluentIterable<T> inOrderTraversal(final T root) {
Preconditions.checkNotNull(root);
return new FluentIterable<T>(){
@Override
public UnmodifiableIterator<T> iterator() {
return new InOrderIterator(root);
}
};
}
private static <T> void pushIfPresent(Deque<T> stack, Optional<T> node) {
if (node.isPresent()) {
stack.addLast(node.get());
}
}
private final class InOrderIterator
extends AbstractIterator<T> {
private final Deque<T> stack = new ArrayDeque();
private final BitSet hasExpandedLeft = new BitSet();
InOrderIterator(T root) {
this.stack.addLast(root);
}
@Override
protected T computeNext() {
while (!this.stack.isEmpty()) {
Object node = this.stack.getLast();
if (this.hasExpandedLeft.get(this.stack.size() - 1)) {
this.stack.removeLast();
this.hasExpandedLeft.clear(this.stack.size());
BinaryTreeTraverser.pushIfPresent(this.stack, BinaryTreeTraverser.this.rightChild(node));
return node;
}
this.hasExpandedLeft.set(this.stack.size() - 1);
BinaryTreeTraverser.pushIfPresent(this.stack, BinaryTreeTraverser.this.leftChild(node));
}
return this.endOfData();
}
}
private final class PostOrderIterator
extends UnmodifiableIterator<T> {
private final Deque<T> stack = new ArrayDeque();
private final BitSet hasExpanded;
PostOrderIterator(T root) {
this.stack.addLast(root);
this.hasExpanded = new BitSet();
}
@Override
public boolean hasNext() {
return !this.stack.isEmpty();
}
@Override
public T next() {
while (true) {
Object node = this.stack.getLast();
boolean expandedNode = this.hasExpanded.get(this.stack.size() - 1);
if (expandedNode) {
this.stack.removeLast();
this.hasExpanded.clear(this.stack.size());
return node;
}
this.hasExpanded.set(this.stack.size() - 1);
BinaryTreeTraverser.pushIfPresent(this.stack, BinaryTreeTraverser.this.rightChild(node));
BinaryTreeTraverser.pushIfPresent(this.stack, BinaryTreeTraverser.this.leftChild(node));
}
}
}
private final class PreOrderIterator
extends UnmodifiableIterator<T>
implements PeekingIterator<T> {
private final Deque<T> stack = new ArrayDeque();
PreOrderIterator(T root) {
this.stack.addLast(root);
}
@Override
public boolean hasNext() {
return !this.stack.isEmpty();
}
@Override
public T next() {
Object result = this.stack.removeLast();
BinaryTreeTraverser.pushIfPresent(this.stack, BinaryTreeTraverser.this.rightChild(result));
BinaryTreeTraverser.pushIfPresent(this.stack, BinaryTreeTraverser.this.leftChild(result));
return result;
}
@Override
public T peek() {
return this.stack.getLast();
}
}
}

View file

@ -0,0 +1,32 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
@GwtCompatible
public enum BoundType {
OPEN{
@Override
BoundType flip() {
return CLOSED;
}
}
,
CLOSED{
@Override
BoundType flip() {
return OPEN;
}
};
static BoundType forBoolean(boolean inclusive) {
return inclusive ? CLOSED : OPEN;
}
abstract BoundType flip();
}

View file

@ -0,0 +1,53 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.collect.Ordering;
import java.io.Serializable;
import javax.annotation.Nullable;
@GwtCompatible(serializable=true)
final class ByFunctionOrdering<F, T>
extends Ordering<F>
implements Serializable {
final Function<F, ? extends T> function;
final Ordering<T> ordering;
private static final long serialVersionUID = 0L;
ByFunctionOrdering(Function<F, ? extends T> function, Ordering<T> ordering) {
this.function = Preconditions.checkNotNull(function);
this.ordering = Preconditions.checkNotNull(ordering);
}
@Override
public int compare(F left, F right) {
return this.ordering.compare(this.function.apply(left), this.function.apply(right));
}
@Override
public boolean equals(@Nullable Object object) {
if (object == this) {
return true;
}
if (object instanceof ByFunctionOrdering) {
ByFunctionOrdering that = (ByFunctionOrdering)object;
return this.function.equals(that.function) && this.ordering.equals(that.ordering);
}
return false;
}
public int hashCode() {
return Objects.hashCode(this.function, this.ordering);
}
public String toString() {
String string = String.valueOf(String.valueOf(this.ordering));
String string2 = String.valueOf(String.valueOf(this.function));
return new StringBuilder(13 + string.length() + string2.length()).append(string).append(".onResultOf(").append(string2).append(")").toString();
}
}

View file

@ -0,0 +1,100 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.math.IntMath;
import java.util.AbstractList;
import java.util.List;
import java.util.ListIterator;
import java.util.RandomAccess;
import javax.annotation.Nullable;
@GwtCompatible
final class CartesianList<E>
extends AbstractList<List<E>>
implements RandomAccess {
private final transient ImmutableList<List<E>> axes;
private final transient int[] axesSizeProduct;
static <E> List<List<E>> create(List<? extends List<? extends E>> lists) {
ImmutableList.Builder axesBuilder = new ImmutableList.Builder(lists.size());
for (List<E> list : lists) {
ImmutableList<E> copy = ImmutableList.copyOf(list);
if (copy.isEmpty()) {
return ImmutableList.of();
}
axesBuilder.add(copy);
}
return new CartesianList<E>(axesBuilder.build());
}
CartesianList(ImmutableList<List<E>> axes) {
this.axes = axes;
int[] axesSizeProduct = new int[axes.size() + 1];
axesSizeProduct[axes.size()] = 1;
try {
for (int i = axes.size() - 1; i >= 0; --i) {
axesSizeProduct[i] = IntMath.checkedMultiply(axesSizeProduct[i + 1], ((List)axes.get(i)).size());
}
}
catch (ArithmeticException e) {
throw new IllegalArgumentException("Cartesian product too large; must have size at most Integer.MAX_VALUE");
}
this.axesSizeProduct = axesSizeProduct;
}
private int getAxisIndexForProductIndex(int index, int axis) {
return index / this.axesSizeProduct[axis + 1] % ((List)this.axes.get(axis)).size();
}
@Override
public ImmutableList<E> get(final int index) {
Preconditions.checkElementIndex(index, this.size());
return new ImmutableList<E>(){
@Override
public int size() {
return CartesianList.this.axes.size();
}
@Override
public E get(int axis) {
Preconditions.checkElementIndex(axis, this.size());
int axisIndex = CartesianList.this.getAxisIndexForProductIndex(index, axis);
return ((List)CartesianList.this.axes.get(axis)).get(axisIndex);
}
@Override
boolean isPartialView() {
return true;
}
};
}
@Override
public int size() {
return this.axesSizeProduct[0];
}
@Override
public boolean contains(@Nullable Object o) {
if (!(o instanceof List)) {
return false;
}
List list = (List)o;
if (list.size() != this.axes.size()) {
return false;
}
ListIterator itr = list.listIterator();
while (itr.hasNext()) {
int index = itr.nextIndex();
if (((List)this.axes.get(index)).contains(itr.next())) continue;
return false;
}
return true;
}
}

View file

@ -0,0 +1,16 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import java.util.Map;
import javax.annotation.Nullable;
@GwtCompatible
public interface ClassToInstanceMap<B>
extends Map<Class<? extends B>, B> {
public <T extends B> T getInstance(Class<T> var1);
public <T extends B> T putInstance(Class<T> var1, @Nullable T var2);
}

View file

@ -0,0 +1,37 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Preconditions;
@GwtCompatible
final class CollectPreconditions {
CollectPreconditions() {
}
static void checkEntryNotNull(Object key, Object value) {
if (key == null) {
String string = String.valueOf(String.valueOf(value));
throw new NullPointerException(new StringBuilder(24 + string.length()).append("null key in entry: null=").append(string).toString());
}
if (value == null) {
String string = String.valueOf(String.valueOf(key));
throw new NullPointerException(new StringBuilder(26 + string.length()).append("null value in entry: ").append(string).append("=null").toString());
}
}
static int checkNonnegative(int value, String name) {
if (value < 0) {
String string = String.valueOf(String.valueOf(name));
int n = value;
throw new IllegalArgumentException(new StringBuilder(40 + string.length()).append(string).append(" cannot be negative but was: ").append(n).toString());
}
return value;
}
static void checkRemove(boolean canRemove) {
Preconditions.checkState(canRemove, "no calls to next() since the last call to remove()");
}
}

View file

@ -0,0 +1,462 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.AbstractIterator;
import com.google.common.collect.CollectPreconditions;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
import com.google.common.math.IntMath;
import com.google.common.math.LongMath;
import java.util.AbstractCollection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import javax.annotation.Nullable;
@GwtCompatible
public final class Collections2 {
static final Joiner STANDARD_JOINER = Joiner.on(", ").useForNull("null");
private Collections2() {
}
public static <E> Collection<E> filter(Collection<E> unfiltered, Predicate<? super E> predicate) {
if (unfiltered instanceof FilteredCollection) {
return ((FilteredCollection)unfiltered).createCombined(predicate);
}
return new FilteredCollection<E>(Preconditions.checkNotNull(unfiltered), Preconditions.checkNotNull(predicate));
}
static boolean safeContains(Collection<?> collection, @Nullable Object object) {
Preconditions.checkNotNull(collection);
try {
return collection.contains(object);
}
catch (ClassCastException e) {
return false;
}
catch (NullPointerException e) {
return false;
}
}
static boolean safeRemove(Collection<?> collection, @Nullable Object object) {
Preconditions.checkNotNull(collection);
try {
return collection.remove(object);
}
catch (ClassCastException e) {
return false;
}
catch (NullPointerException e) {
return false;
}
}
public static <F, T> Collection<T> transform(Collection<F> fromCollection, Function<? super F, T> function) {
return new TransformedCollection<F, T>(fromCollection, function);
}
static boolean containsAllImpl(Collection<?> self, Collection<?> c) {
return Iterables.all(c, Predicates.in(self));
}
static String toStringImpl(final Collection<?> collection) {
StringBuilder sb = Collections2.newStringBuilderForCollection(collection.size()).append('[');
STANDARD_JOINER.appendTo(sb, Iterables.transform(collection, new Function<Object, Object>(){
@Override
public Object apply(Object input) {
return input == collection ? "(this Collection)" : input;
}
}));
return sb.append(']').toString();
}
static StringBuilder newStringBuilderForCollection(int size) {
CollectPreconditions.checkNonnegative(size, "size");
return new StringBuilder((int)Math.min((long)size * 8L, 0x40000000L));
}
static <T> Collection<T> cast(Iterable<T> iterable) {
return (Collection)iterable;
}
@Beta
public static <E extends Comparable<? super E>> Collection<List<E>> orderedPermutations(Iterable<E> elements) {
return Collections2.orderedPermutations(elements, Ordering.natural());
}
@Beta
public static <E> Collection<List<E>> orderedPermutations(Iterable<E> elements, Comparator<? super E> comparator) {
return new OrderedPermutationCollection<E>(elements, comparator);
}
@Beta
public static <E> Collection<List<E>> permutations(Collection<E> elements) {
return new PermutationCollection<E>(ImmutableList.copyOf(elements));
}
private static boolean isPermutation(List<?> first, List<?> second) {
if (first.size() != second.size()) {
return false;
}
HashMultiset<?> firstMultiset = HashMultiset.create(first);
HashMultiset<?> secondMultiset = HashMultiset.create(second);
return firstMultiset.equals(secondMultiset);
}
private static boolean isPositiveInt(long n) {
return n >= 0L && n <= Integer.MAX_VALUE;
}
private static class PermutationIterator<E>
extends AbstractIterator<List<E>> {
final List<E> list;
final int[] c;
final int[] o;
int j;
PermutationIterator(List<E> list) {
this.list = new ArrayList<E>(list);
int n = list.size();
this.c = new int[n];
this.o = new int[n];
Arrays.fill(this.c, 0);
Arrays.fill(this.o, 1);
this.j = Integer.MAX_VALUE;
}
@Override
protected List<E> computeNext() {
if (this.j <= 0) {
return (List)this.endOfData();
}
ImmutableList<E> next = ImmutableList.copyOf(this.list);
this.calculateNextPermutation();
return next;
}
void calculateNextPermutation() {
block4: {
int q;
this.j = this.list.size() - 1;
int s = 0;
if (this.j == -1) {
return;
}
while (true) {
if ((q = this.c[this.j] + this.o[this.j]) < 0) {
this.switchDirection();
continue;
}
if (q != this.j + 1) break;
if (this.j != 0) {
++s;
this.switchDirection();
continue;
}
break block4;
break;
}
Collections.swap(this.list, this.j - this.c[this.j] + s, this.j - q + s);
this.c[this.j] = q;
}
}
void switchDirection() {
this.o[this.j] = -this.o[this.j];
--this.j;
}
}
private static final class PermutationCollection<E>
extends AbstractCollection<List<E>> {
final ImmutableList<E> inputList;
PermutationCollection(ImmutableList<E> input) {
this.inputList = input;
}
@Override
public int size() {
return IntMath.factorial(this.inputList.size());
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public Iterator<List<E>> iterator() {
return new PermutationIterator<E>(this.inputList);
}
@Override
public boolean contains(@Nullable Object obj) {
if (obj instanceof List) {
List list = (List)obj;
return Collections2.isPermutation(this.inputList, list);
}
return false;
}
@Override
public String toString() {
String string = String.valueOf(String.valueOf(this.inputList));
return new StringBuilder(14 + string.length()).append("permutations(").append(string).append(")").toString();
}
}
private static final class OrderedPermutationIterator<E>
extends AbstractIterator<List<E>> {
List<E> nextPermutation;
final Comparator<? super E> comparator;
OrderedPermutationIterator(List<E> list, Comparator<? super E> comparator) {
this.nextPermutation = Lists.newArrayList(list);
this.comparator = comparator;
}
@Override
protected List<E> computeNext() {
if (this.nextPermutation == null) {
return (List)this.endOfData();
}
ImmutableList<E> next = ImmutableList.copyOf(this.nextPermutation);
this.calculateNextPermutation();
return next;
}
void calculateNextPermutation() {
int j = this.findNextJ();
if (j == -1) {
this.nextPermutation = null;
return;
}
int l = this.findNextL(j);
Collections.swap(this.nextPermutation, j, l);
int n = this.nextPermutation.size();
Collections.reverse(this.nextPermutation.subList(j + 1, n));
}
int findNextJ() {
for (int k = this.nextPermutation.size() - 2; k >= 0; --k) {
if (this.comparator.compare(this.nextPermutation.get(k), this.nextPermutation.get(k + 1)) >= 0) continue;
return k;
}
return -1;
}
int findNextL(int j) {
E ak = this.nextPermutation.get(j);
for (int l = this.nextPermutation.size() - 1; l > j; --l) {
if (this.comparator.compare(ak, this.nextPermutation.get(l)) >= 0) continue;
return l;
}
throw new AssertionError((Object)"this statement should be unreachable");
}
}
private static final class OrderedPermutationCollection<E>
extends AbstractCollection<List<E>> {
final ImmutableList<E> inputList;
final Comparator<? super E> comparator;
final int size;
OrderedPermutationCollection(Iterable<E> input, Comparator<? super E> comparator) {
this.inputList = Ordering.from(comparator).immutableSortedCopy(input);
this.comparator = comparator;
this.size = OrderedPermutationCollection.calculateSize(this.inputList, comparator);
}
private static <E> int calculateSize(List<E> sortedInputList, Comparator<? super E> comparator) {
long permutations = 1L;
int n = 1;
int r = 1;
while (n < sortedInputList.size()) {
int comparison = comparator.compare(sortedInputList.get(n - 1), sortedInputList.get(n));
if (comparison < 0) {
permutations *= LongMath.binomial(n, r);
r = 0;
if (!Collections2.isPositiveInt(permutations)) {
return Integer.MAX_VALUE;
}
}
++n;
++r;
}
if (!Collections2.isPositiveInt(permutations *= LongMath.binomial(n, r))) {
return Integer.MAX_VALUE;
}
return (int)permutations;
}
@Override
public int size() {
return this.size;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public Iterator<List<E>> iterator() {
return new OrderedPermutationIterator<E>(this.inputList, this.comparator);
}
@Override
public boolean contains(@Nullable Object obj) {
if (obj instanceof List) {
List list = (List)obj;
return Collections2.isPermutation(this.inputList, list);
}
return false;
}
@Override
public String toString() {
String string = String.valueOf(String.valueOf(this.inputList));
return new StringBuilder(30 + string.length()).append("orderedPermutationCollection(").append(string).append(")").toString();
}
}
static class TransformedCollection<F, T>
extends AbstractCollection<T> {
final Collection<F> fromCollection;
final Function<? super F, ? extends T> function;
TransformedCollection(Collection<F> fromCollection, Function<? super F, ? extends T> function) {
this.fromCollection = Preconditions.checkNotNull(fromCollection);
this.function = Preconditions.checkNotNull(function);
}
@Override
public void clear() {
this.fromCollection.clear();
}
@Override
public boolean isEmpty() {
return this.fromCollection.isEmpty();
}
@Override
public Iterator<T> iterator() {
return Iterators.transform(this.fromCollection.iterator(), this.function);
}
@Override
public int size() {
return this.fromCollection.size();
}
}
static class FilteredCollection<E>
extends AbstractCollection<E> {
final Collection<E> unfiltered;
final Predicate<? super E> predicate;
FilteredCollection(Collection<E> unfiltered, Predicate<? super E> predicate) {
this.unfiltered = unfiltered;
this.predicate = predicate;
}
FilteredCollection<E> createCombined(Predicate<? super E> newPredicate) {
return new FilteredCollection<E>(this.unfiltered, Predicates.and(this.predicate, newPredicate));
}
@Override
public boolean add(E element) {
Preconditions.checkArgument(this.predicate.apply(element));
return this.unfiltered.add(element);
}
@Override
public boolean addAll(Collection<? extends E> collection) {
for (E element : collection) {
Preconditions.checkArgument(this.predicate.apply(element));
}
return this.unfiltered.addAll(collection);
}
@Override
public void clear() {
Iterables.removeIf(this.unfiltered, this.predicate);
}
@Override
public boolean contains(@Nullable Object element) {
if (Collections2.safeContains(this.unfiltered, element)) {
Object e = element;
return this.predicate.apply(e);
}
return false;
}
@Override
public boolean containsAll(Collection<?> collection) {
return Collections2.containsAllImpl(this, collection);
}
@Override
public boolean isEmpty() {
return !Iterables.any(this.unfiltered, this.predicate);
}
@Override
public Iterator<E> iterator() {
return Iterators.filter(this.unfiltered.iterator(), this.predicate);
}
@Override
public boolean remove(Object element) {
return this.contains(element) && this.unfiltered.remove(element);
}
@Override
public boolean removeAll(Collection<?> collection) {
return Iterables.removeIf(this.unfiltered, Predicates.and(this.predicate, Predicates.in(collection)));
}
@Override
public boolean retainAll(Collection<?> collection) {
return Iterables.removeIf(this.unfiltered, Predicates.and(this.predicate, Predicates.not(Predicates.in(collection))));
}
@Override
public int size() {
return Iterators.size(this.iterator());
}
@Override
public Object[] toArray() {
return Lists.newArrayList(this.iterator()).toArray();
}
@Override
public <T> T[] toArray(T[] array) {
return Lists.newArrayList(this.iterator()).toArray(array);
}
}
}

View file

@ -0,0 +1,48 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Preconditions;
import com.google.common.collect.Ordering;
import java.io.Serializable;
import java.util.Comparator;
import javax.annotation.Nullable;
@GwtCompatible(serializable=true)
final class ComparatorOrdering<T>
extends Ordering<T>
implements Serializable {
final Comparator<T> comparator;
private static final long serialVersionUID = 0L;
ComparatorOrdering(Comparator<T> comparator) {
this.comparator = Preconditions.checkNotNull(comparator);
}
@Override
public int compare(T a, T b) {
return this.comparator.compare(a, b);
}
@Override
public boolean equals(@Nullable Object object) {
if (object == this) {
return true;
}
if (object instanceof ComparatorOrdering) {
ComparatorOrdering that = (ComparatorOrdering)object;
return this.comparator.equals(that.comparator);
}
return false;
}
public int hashCode() {
return this.comparator.hashCode();
}
public String toString() {
return this.comparator.toString();
}
}

View file

@ -0,0 +1,145 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.primitives.Booleans;
import com.google.common.primitives.Ints;
import com.google.common.primitives.Longs;
import java.util.Comparator;
import javax.annotation.Nullable;
@GwtCompatible
public abstract class ComparisonChain {
private static final ComparisonChain ACTIVE = new ComparisonChain(){
public ComparisonChain compare(Comparable left, Comparable right) {
return this.classify(left.compareTo(right));
}
@Override
public <T> ComparisonChain compare(@Nullable T left, @Nullable T right, Comparator<T> comparator) {
return this.classify(comparator.compare(left, right));
}
@Override
public ComparisonChain compare(int left, int right) {
return this.classify(Ints.compare(left, right));
}
@Override
public ComparisonChain compare(long left, long right) {
return this.classify(Longs.compare(left, right));
}
@Override
public ComparisonChain compare(float left, float right) {
return this.classify(Float.compare(left, right));
}
@Override
public ComparisonChain compare(double left, double right) {
return this.classify(Double.compare(left, right));
}
@Override
public ComparisonChain compareTrueFirst(boolean left, boolean right) {
return this.classify(Booleans.compare(right, left));
}
@Override
public ComparisonChain compareFalseFirst(boolean left, boolean right) {
return this.classify(Booleans.compare(left, right));
}
ComparisonChain classify(int result) {
return result < 0 ? LESS : (result > 0 ? GREATER : ACTIVE);
}
@Override
public int result() {
return 0;
}
};
private static final ComparisonChain LESS = new InactiveComparisonChain(-1);
private static final ComparisonChain GREATER = new InactiveComparisonChain(1);
private ComparisonChain() {
}
public static ComparisonChain start() {
return ACTIVE;
}
public abstract ComparisonChain compare(Comparable<?> var1, Comparable<?> var2);
public abstract <T> ComparisonChain compare(@Nullable T var1, @Nullable T var2, Comparator<T> var3);
public abstract ComparisonChain compare(int var1, int var2);
public abstract ComparisonChain compare(long var1, long var3);
public abstract ComparisonChain compare(float var1, float var2);
public abstract ComparisonChain compare(double var1, double var3);
public abstract ComparisonChain compareTrueFirst(boolean var1, boolean var2);
public abstract ComparisonChain compareFalseFirst(boolean var1, boolean var2);
public abstract int result();
private static final class InactiveComparisonChain
extends ComparisonChain {
final int result;
InactiveComparisonChain(int result) {
this.result = result;
}
public ComparisonChain compare(@Nullable Comparable left, @Nullable Comparable right) {
return this;
}
@Override
public <T> ComparisonChain compare(@Nullable T left, @Nullable T right, @Nullable Comparator<T> comparator) {
return this;
}
@Override
public ComparisonChain compare(int left, int right) {
return this;
}
@Override
public ComparisonChain compare(long left, long right) {
return this;
}
@Override
public ComparisonChain compare(float left, float right) {
return this;
}
@Override
public ComparisonChain compare(double left, double right) {
return this;
}
@Override
public ComparisonChain compareTrueFirst(boolean left, boolean right) {
return this;
}
@Override
public ComparisonChain compareFalseFirst(boolean left, boolean right) {
return this;
}
@Override
public int result() {
return this.result;
}
}
}

View file

@ -0,0 +1,58 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Ordering;
import java.io.Serializable;
import java.util.Comparator;
@GwtCompatible(serializable=true)
final class CompoundOrdering<T>
extends Ordering<T>
implements Serializable {
final ImmutableList<Comparator<? super T>> comparators;
private static final long serialVersionUID = 0L;
CompoundOrdering(Comparator<? super T> primary, Comparator<? super T> secondary) {
this.comparators = ImmutableList.of(primary, secondary);
}
CompoundOrdering(Iterable<? extends Comparator<? super T>> comparators) {
this.comparators = ImmutableList.copyOf(comparators);
}
@Override
public int compare(T left, T right) {
int size = this.comparators.size();
for (int i = 0; i < size; ++i) {
int result = ((Comparator)this.comparators.get(i)).compare(left, right);
if (result == 0) continue;
return result;
}
return 0;
}
@Override
public boolean equals(Object object) {
if (object == this) {
return true;
}
if (object instanceof CompoundOrdering) {
CompoundOrdering that = (CompoundOrdering)object;
return this.comparators.equals(that.comparators);
}
return false;
}
public int hashCode() {
return this.comparators.hashCode();
}
public String toString() {
String string = String.valueOf(String.valueOf(this.comparators));
return new StringBuilder(19 + string.length()).append("Ordering.compound(").append(string).append(")").toString();
}
}

View file

@ -0,0 +1,17 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import javax.annotation.Nullable;
@GwtCompatible
public class ComputationException
extends RuntimeException {
private static final long serialVersionUID = 0L;
public ComputationException(@Nullable Throwable cause) {
super(cause);
}
}

View file

@ -0,0 +1,365 @@
/*
* Decompiled with CFR 0.152.
*/
package com.google.common.collect;
import com.google.common.base.Equivalence;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.MapMaker;
import com.google.common.collect.MapMakerInternalMap;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.ref.ReferenceQueue;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicReferenceArray;
import javax.annotation.Nullable;
import javax.annotation.concurrent.GuardedBy;
class ComputingConcurrentHashMap<K, V>
extends MapMakerInternalMap<K, V> {
final Function<? super K, ? extends V> computingFunction;
private static final long serialVersionUID = 4L;
ComputingConcurrentHashMap(MapMaker builder, Function<? super K, ? extends V> computingFunction) {
super(builder);
this.computingFunction = Preconditions.checkNotNull(computingFunction);
}
@Override
MapMakerInternalMap.Segment<K, V> createSegment(int initialCapacity, int maxSegmentSize) {
return new ComputingSegment(this, initialCapacity, maxSegmentSize);
}
@Override
ComputingSegment<K, V> segmentFor(int hash) {
return (ComputingSegment)super.segmentFor(hash);
}
V getOrCompute(K key) throws ExecutionException {
int hash = this.hash(Preconditions.checkNotNull(key));
return ((ComputingSegment)this.segmentFor(hash)).getOrCompute(key, hash, this.computingFunction);
}
@Override
Object writeReplace() {
return new ComputingSerializationProxy<K, V>(this.keyStrength, this.valueStrength, this.keyEquivalence, this.valueEquivalence, this.expireAfterWriteNanos, this.expireAfterAccessNanos, this.maximumSize, this.concurrencyLevel, this.removalListener, this, this.computingFunction);
}
static final class ComputingSerializationProxy<K, V>
extends MapMakerInternalMap.AbstractSerializationProxy<K, V> {
final Function<? super K, ? extends V> computingFunction;
private static final long serialVersionUID = 4L;
ComputingSerializationProxy(MapMakerInternalMap.Strength keyStrength, MapMakerInternalMap.Strength valueStrength, Equivalence<Object> keyEquivalence, Equivalence<Object> valueEquivalence, long expireAfterWriteNanos, long expireAfterAccessNanos, int maximumSize, int concurrencyLevel, MapMaker.RemovalListener<? super K, ? super V> removalListener, ConcurrentMap<K, V> delegate, Function<? super K, ? extends V> computingFunction) {
super(keyStrength, valueStrength, keyEquivalence, valueEquivalence, expireAfterWriteNanos, expireAfterAccessNanos, maximumSize, concurrencyLevel, removalListener, delegate);
this.computingFunction = computingFunction;
}
private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
this.writeMapTo(out);
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
MapMaker mapMaker = this.readMapMaker(in);
this.delegate = mapMaker.makeComputingMap(this.computingFunction);
this.readEntries(in);
}
Object readResolve() {
return this.delegate;
}
}
private static final class ComputingValueReference<K, V>
implements MapMakerInternalMap.ValueReference<K, V> {
final Function<? super K, ? extends V> computingFunction;
@GuardedBy(value="ComputingValueReference.this")
volatile MapMakerInternalMap.ValueReference<K, V> computedReference = MapMakerInternalMap.unset();
public ComputingValueReference(Function<? super K, ? extends V> computingFunction) {
this.computingFunction = computingFunction;
}
@Override
public V get() {
return null;
}
@Override
public MapMakerInternalMap.ReferenceEntry<K, V> getEntry() {
return null;
}
@Override
public MapMakerInternalMap.ValueReference<K, V> copyFor(ReferenceQueue<V> queue, @Nullable V value, MapMakerInternalMap.ReferenceEntry<K, V> entry) {
return this;
}
@Override
public boolean isComputingReference() {
return true;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
@Override
public V waitForValue() throws ExecutionException {
if (this.computedReference == MapMakerInternalMap.UNSET) {
boolean interrupted = false;
try {
ComputingValueReference computingValueReference = this;
synchronized (computingValueReference) {
while (this.computedReference == MapMakerInternalMap.UNSET) {
try {
this.wait();
}
catch (InterruptedException ie) {
interrupted = true;
}
}
}
}
finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
}
return this.computedReference.waitForValue();
}
@Override
public void clear(MapMakerInternalMap.ValueReference<K, V> newValue) {
this.setValueReference(newValue);
}
V compute(K key, int hash) throws ExecutionException {
V value;
try {
value = this.computingFunction.apply(key);
}
catch (Throwable t) {
this.setValueReference(new ComputationExceptionReference(t));
throw new ExecutionException(t);
}
this.setValueReference(new ComputedReference(value));
return value;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
void setValueReference(MapMakerInternalMap.ValueReference<K, V> valueReference) {
ComputingValueReference computingValueReference = this;
synchronized (computingValueReference) {
if (this.computedReference == MapMakerInternalMap.UNSET) {
this.computedReference = valueReference;
this.notifyAll();
}
}
}
}
private static final class ComputedReference<K, V>
implements MapMakerInternalMap.ValueReference<K, V> {
final V value;
ComputedReference(@Nullable V value) {
this.value = value;
}
@Override
public V get() {
return this.value;
}
@Override
public MapMakerInternalMap.ReferenceEntry<K, V> getEntry() {
return null;
}
@Override
public MapMakerInternalMap.ValueReference<K, V> copyFor(ReferenceQueue<V> queue, V value, MapMakerInternalMap.ReferenceEntry<K, V> entry) {
return this;
}
@Override
public boolean isComputingReference() {
return false;
}
@Override
public V waitForValue() {
return this.get();
}
@Override
public void clear(MapMakerInternalMap.ValueReference<K, V> newValue) {
}
}
private static final class ComputationExceptionReference<K, V>
implements MapMakerInternalMap.ValueReference<K, V> {
final Throwable t;
ComputationExceptionReference(Throwable t) {
this.t = t;
}
@Override
public V get() {
return null;
}
@Override
public MapMakerInternalMap.ReferenceEntry<K, V> getEntry() {
return null;
}
@Override
public MapMakerInternalMap.ValueReference<K, V> copyFor(ReferenceQueue<V> queue, V value, MapMakerInternalMap.ReferenceEntry<K, V> entry) {
return this;
}
@Override
public boolean isComputingReference() {
return false;
}
@Override
public V waitForValue() throws ExecutionException {
throw new ExecutionException(this.t);
}
@Override
public void clear(MapMakerInternalMap.ValueReference<K, V> newValue) {
}
}
static final class ComputingSegment<K, V>
extends MapMakerInternalMap.Segment<K, V> {
ComputingSegment(MapMakerInternalMap<K, V> map, int initialCapacity, int maxSegmentSize) {
super(map, initialCapacity, maxSegmentSize);
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
V getOrCompute(K key, int hash, Function<? super K, ? extends V> computingFunction) throws ExecutionException {
try {
Object v;
MapMakerInternalMap.ReferenceEntry<Object, Object> e;
Object value;
do {
if ((e = this.getEntry(key, hash)) != null && (value = this.getLiveValue(e)) != null) {
this.recordRead(e);
v = value;
return v;
}
if (e == null || !e.getValueReference().isComputingReference()) {
ComputingValueReference<? super K, ? extends V> computingValueReference;
boolean createNewEntry;
block22: {
createNewEntry = true;
computingValueReference = null;
this.lock();
try {
MapMakerInternalMap.ReferenceEntry<Object, Object> first;
this.preWriteCleanup();
int newCount = this.count - 1;
AtomicReferenceArray table = this.table;
int index = hash & table.length() - 1;
for (e = first = (MapMakerInternalMap.ReferenceEntry<Object, Object>)table.get(index); e != null; e = e.getNext()) {
Object entryKey = e.getKey();
if (e.getHash() != hash || entryKey == null || !this.map.keyEquivalence.equivalent(key, entryKey)) continue;
MapMakerInternalMap.ValueReference valueReference = e.getValueReference();
if (valueReference.isComputingReference()) {
createNewEntry = false;
break;
}
Object value2 = e.getValueReference().get();
if (value2 == null) {
this.enqueueNotification(entryKey, hash, value2, MapMaker.RemovalCause.COLLECTED);
} else if (this.map.expires() && this.map.isExpired(e)) {
this.enqueueNotification(entryKey, hash, value2, MapMaker.RemovalCause.EXPIRED);
} else {
this.recordLockedRead(e);
Object v2 = value2;
return v2;
}
this.evictionQueue.remove(e);
this.expirationQueue.remove(e);
this.count = newCount;
break;
}
if (!createNewEntry) break block22;
computingValueReference = new ComputingValueReference<K, V>(computingFunction);
if (e == null) {
e = this.newEntry(key, hash, first);
e.setValueReference(computingValueReference);
table.set(index, e);
} else {
e.setValueReference(computingValueReference);
}
}
finally {
this.unlock();
this.postWriteCleanup();
}
}
if (createNewEntry) {
V v3 = this.compute(key, hash, e, computingValueReference);
return v3;
}
}
Preconditions.checkState(!Thread.holdsLock(e), "Recursive computation");
} while ((value = e.getValueReference().waitForValue()) == null);
this.recordRead(e);
v = value;
return v;
}
finally {
this.postReadCleanup();
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
V compute(K key, int hash, MapMakerInternalMap.ReferenceEntry<K, V> e, ComputingValueReference<K, V> computingValueReference) throws ExecutionException {
Object value = null;
long start = System.nanoTime();
long end = 0L;
try {
Object oldValue;
MapMakerInternalMap.ReferenceEntry<K, V> referenceEntry = e;
synchronized (referenceEntry) {
value = computingValueReference.compute(key, hash);
end = System.nanoTime();
}
if (value != null && (oldValue = this.put(key, hash, value, true)) != null) {
this.enqueueNotification(key, hash, value, MapMaker.RemovalCause.REPLACED);
}
referenceEntry = value;
return (V)referenceEntry;
}
finally {
if (end == 0L) {
end = System.nanoTime();
}
if (value == null) {
this.clearValue(key, hash, computingValueReference);
}
}
}
}
}

Some files were not shown because too many files have changed in this diff Show more