try new-method

This commit is contained in:
Merith-TK 2022-08-09 23:00:29 -07:00
parent 78237d9c80
commit 52b4651f1a
3812 changed files with 228702 additions and 223704 deletions

5
Readme.md Normal file
View file

@ -0,0 +1,5 @@
decompiled SkaiaCraft launcher with personal tweaks and bugfixes
## Disclaimer
* Decompiled with [CFR](http://www.benf.org/other/cfr/)
* Made easier with [My CFR Helper](https://github.com/Merith-TK/cfr)

BIN
cfr.jar Normal file

Binary file not shown.

Binary file not shown.

View file

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View file

Before

Width:  |  Height:  |  Size: 199 B

After

Width:  |  Height:  |  Size: 199 B

View file

@ -0,0 +1,27 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.error;
import java.io.IOException;
public class TagNotFoundException
extends IOException {
private static final long serialVersionUID = -4631008535746749103L;
public TagNotFoundException() {
super("The tag does not exist");
}
public TagNotFoundException(String message) {
super(message);
}
public TagNotFoundException(Throwable cause) {
super(cause);
}
public TagNotFoundException(String message, Throwable cause) {
super(message, cause);
}
}

View file

@ -0,0 +1,27 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.error;
import java.io.IOException;
public class UnexpectedTagTypeException
extends IOException {
private static final long serialVersionUID = -6604963428978583800L;
public UnexpectedTagTypeException() {
super("The tag is not of the expected type");
}
public UnexpectedTagTypeException(String message) {
super(message);
}
public UnexpectedTagTypeException(Throwable cause) {
super(cause);
}
public UnexpectedTagTypeException(String message, Throwable cause) {
super(message, cause);
}
}

View file

@ -0,0 +1,46 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.stream;
import com.evilco.mc.nbt.tag.ITag;
import com.evilco.mc.nbt.tag.TagType;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
public class NbtInputStream
extends DataInputStream {
public NbtInputStream(InputStream in) {
super(in);
}
public ITag readTag() throws IOException {
byte type = this.readByte();
TagType tagType = TagType.valueOf(type);
if (tagType == null) {
throw new IOException("Invalid NBT tag: Found unknown tag type " + type + ".");
}
if (tagType == TagType.END) {
return null;
}
return this.readTag(tagType, false);
}
public ITag readTag(TagType type, boolean anonymous) throws IOException {
Constructor<? extends ITag> constructor = null;
try {
constructor = type.tagType.getConstructor(NbtInputStream.class, Boolean.TYPE);
}
catch (NoSuchMethodException ex) {
throw new IOException("Invalid NBT implementation state: Type " + type.tagType.getName() + " has no de-serialization constructor.");
}
try {
return constructor.newInstance(this, anonymous);
}
catch (Exception ex) {
throw new IOException("Invalid NBT implementation state: Type " + type.tagType.getName() + " in (" + this.getClass().getName() + ") has no valid constructor: " + ex.getMessage(), ex);
}
}
}

View file

@ -0,0 +1,21 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.stream;
import com.evilco.mc.nbt.tag.ITag;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class NbtOutputStream
extends DataOutputStream {
public NbtOutputStream(OutputStream out) {
super(out);
}
public void write(ITag tag) throws IOException {
this.writeByte(tag.getTagID());
tag.write(this, false);
}
}

View file

@ -0,0 +1,86 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.IAnonymousTagContainer;
import com.evilco.mc.nbt.tag.INamedTagContainer;
import com.evilco.mc.nbt.tag.ITag;
import com.evilco.mc.nbt.tag.ITagContainer;
import com.google.common.base.Preconditions;
import java.io.IOException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public abstract class AbstractTag
implements ITag {
protected String name;
protected ITagContainer parent = null;
public AbstractTag(@Nonnull String name) {
this.setName(name);
}
public AbstractTag(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
Preconditions.checkNotNull(inputStream, "inputStream");
if (!anonymous) {
short nameSize = inputStream.readShort();
byte[] nameBytes = new byte[nameSize];
inputStream.readFully(nameBytes);
this.setName(new String(nameBytes, STRING_CHARSET));
}
}
@Override
public String getName() {
return this.name;
}
@Override
public byte[] getNameBytes() {
return this.name.getBytes(STRING_CHARSET);
}
@Override
public ITagContainer getParent() {
return this.parent;
}
@Override
public abstract byte getTagID();
@Override
public void setName(@Nonnull String name) {
Preconditions.checkNotNull(name, "name");
if (this.getParent() != null) {
this.getParent().removeTag(this);
}
this.name = name;
if (this.getParent() != null) {
if (this.getParent() instanceof IAnonymousTagContainer) {
((IAnonymousTagContainer)this.getParent()).addTag(this);
} else {
((INamedTagContainer)this.getParent()).setTag(this);
}
}
}
@Override
public void setParent(@Nullable ITagContainer parent) {
if (this.getParent() != null) {
this.getParent().removeTag(this);
}
this.parent = parent;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
if (!anonymous) {
byte[] name = this.getNameBytes();
outputStream.writeShort(name.length);
outputStream.write(name);
}
}
}

View file

@ -0,0 +1,21 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.error.UnexpectedTagTypeException;
import com.evilco.mc.nbt.tag.ITag;
import com.evilco.mc.nbt.tag.ITagContainer;
import java.util.List;
import javax.annotation.Nonnull;
public interface IAnonymousTagContainer
extends ITagContainer {
public void addTag(@Nonnull ITag var1);
public List<ITag> getTags();
public <T extends ITag> List<T> getTags(Class<T> var1) throws UnexpectedTagTypeException;
public void setTag(int var1, @Nonnull ITag var2);
}

View file

@ -0,0 +1,24 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.error.TagNotFoundException;
import com.evilco.mc.nbt.error.UnexpectedTagTypeException;
import com.evilco.mc.nbt.tag.ITag;
import com.evilco.mc.nbt.tag.ITagContainer;
import java.util.Map;
import javax.annotation.Nonnull;
public interface INamedTagContainer
extends ITagContainer {
public ITag getTag(@Nonnull String var1);
public <T extends ITag> T getTag(String var1, Class<T> var2) throws UnexpectedTagTypeException, TagNotFoundException;
public Map<String, ITag> getTags();
public void removeTag(@Nonnull String var1);
public void setTag(@Nonnull ITag var1);
}

View file

@ -0,0 +1,29 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.ITagContainer;
import java.io.IOException;
import java.nio.charset.Charset;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public interface ITag {
public static final Charset STRING_CHARSET = Charset.forName("UTF-8");
public String getName();
public byte[] getNameBytes();
public ITagContainer getParent();
public byte getTagID();
public void setName(@Nonnull String var1);
public void setParent(@Nullable ITagContainer var1);
public void write(NbtOutputStream var1, boolean var2) throws IOException;
}

View file

@ -0,0 +1,12 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.tag.ITag;
import javax.annotation.Nonnull;
public interface ITagContainer
extends ITag {
public void removeTag(@Nonnull ITag var1);
}

View file

@ -0,0 +1,45 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.TagType;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagByte
extends AbstractTag {
protected byte value;
public TagByte(@Nonnull String name, byte value) {
super(name);
this.setValue(value);
}
public TagByte(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
this.setValue(inputStream.readByte());
}
@Override
public byte getTagID() {
return TagType.BYTE.typeID;
}
public byte getValue() {
return this.value;
}
public void setValue(byte b) {
this.value = b;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.write(this.getValue());
}
}

View file

@ -0,0 +1,51 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.TagType;
import com.google.common.base.Preconditions;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagByteArray
extends AbstractTag {
protected byte[] value;
public TagByteArray(@Nonnull String name, @Nonnull byte[] value) {
super(name);
this.setValue(value);
}
public TagByteArray(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
int size = inputStream.readInt();
byte[] data = new byte[size];
inputStream.readFully(data);
this.setValue(data);
}
@Override
public byte getTagID() {
return TagType.BYTE_ARRAY.typeID;
}
public byte[] getValue() {
return this.value;
}
public void setValue(@Nonnull byte[] b) {
Preconditions.checkNotNull(b, "b");
this.value = b;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.writeInt(this.value.length);
outputStream.write(this.value);
}
}

View file

@ -0,0 +1,184 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.error.TagNotFoundException;
import com.evilco.mc.nbt.error.UnexpectedTagTypeException;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.INamedTagContainer;
import com.evilco.mc.nbt.tag.ITag;
import com.evilco.mc.nbt.tag.TagByte;
import com.evilco.mc.nbt.tag.TagByteArray;
import com.evilco.mc.nbt.tag.TagDouble;
import com.evilco.mc.nbt.tag.TagFloat;
import com.evilco.mc.nbt.tag.TagInteger;
import com.evilco.mc.nbt.tag.TagIntegerArray;
import com.evilco.mc.nbt.tag.TagList;
import com.evilco.mc.nbt.tag.TagLong;
import com.evilco.mc.nbt.tag.TagShort;
import com.evilco.mc.nbt.tag.TagString;
import com.evilco.mc.nbt.tag.TagType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
public class TagCompound
extends AbstractTag
implements INamedTagContainer {
protected Map<String, ITag> tags = new HashMap<String, ITag>();
public TagCompound(String name) {
super(name);
}
public TagCompound(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
while (true) {
byte type;
TagType tagType;
if ((tagType = TagType.valueOf(type = inputStream.readByte())) == null) {
throw new IOException("Could not find a tag for type ID " + type + ".");
}
if (tagType == TagType.END) break;
this.setTag(inputStream.readTag(tagType, false));
}
}
@Override
public ITag getTag(@Nonnull String name) {
Preconditions.checkNotNull(name, "name");
return this.tags.get(name);
}
@Override
public <T extends ITag> T getTag(String name, Class<T> tagClass) throws UnexpectedTagTypeException, TagNotFoundException {
ITag tag = this.getTag(name);
if (tag == null) {
throw new TagNotFoundException("The compound tag is missing a " + name + " entry");
}
if (!tagClass.isInstance(tag)) {
throw new UnexpectedTagTypeException("The compound entry " + name + " should be of type " + tagClass.getSimpleName() + ", but is of type " + tag.getClass().getSimpleName());
}
return (T)tag;
}
public TagCompound getCompound(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagCompound.class);
}
public int getInteger(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagInteger.class).getValue();
}
public short getShort(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagShort.class).getValue();
}
public byte getByte(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagByte.class).getValue();
}
public long getLong(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagLong.class).getValue();
}
public double getDouble(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagDouble.class).getValue();
}
public float getFloat(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagFloat.class).getValue();
}
public String getString(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagString.class).getValue();
}
public <T extends ITag> List<T> getList(String name, Class<T> itemClass) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagList.class).getTags(itemClass);
}
public int[] getIntegerArray(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagIntegerArray.class).getValues();
}
public byte[] getByteArray(String name) throws UnexpectedTagTypeException, TagNotFoundException {
return this.getTag(name, TagByteArray.class).getValue();
}
public String[] getStringArray(String name) throws UnexpectedTagTypeException, TagNotFoundException {
List<TagString> tags = this.getList(name, TagString.class);
String[] array = new String[tags.size()];
for (int i = 0; i < tags.size(); ++i) {
array[i] = tags.get(i).getValue();
}
return array;
}
public double[] getDoubleArray(String name) throws UnexpectedTagTypeException, TagNotFoundException {
List<TagDouble> tags = this.getList(name, TagDouble.class);
double[] array = new double[tags.size()];
for (int i = 0; i < tags.size(); ++i) {
array[i] = tags.get(i).getValue();
}
return array;
}
public float[] getFloatArray(String name) throws UnexpectedTagTypeException, TagNotFoundException {
List<TagFloat> tags = this.getList(name, TagFloat.class);
float[] array = new float[tags.size()];
for (int i = 0; i < tags.size(); ++i) {
array[i] = tags.get(i).getValue();
}
return array;
}
@Override
public Map<String, ITag> getTags() {
return new ImmutableMap.Builder<String, ITag>().putAll(this.tags).build();
}
@Override
public void removeTag(@Nonnull ITag tag) {
Preconditions.checkNotNull(tag, "tag");
this.tags.remove(tag.getName());
}
@Override
public void removeTag(@Nonnull String tag) {
Preconditions.checkNotNull(tag, "tag");
this.tags.remove(tag);
}
@Override
public void setTag(@Nonnull ITag tag) {
Preconditions.checkNotNull(tag, "tag");
if (this.tags.containsKey(tag)) {
this.tags.get(tag.getName()).setParent(null);
}
this.tags.put(tag.getName(), tag);
tag.setParent(this);
}
@Override
public byte getTagID() {
return TagType.COMPOUND.typeID;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
for (Map.Entry<String, ITag> tagEntry : this.tags.entrySet()) {
outputStream.writeByte(tagEntry.getValue().getTagID());
tagEntry.getValue().write(outputStream, false);
}
outputStream.writeByte(TagType.END.typeID);
}
}

View file

@ -0,0 +1,45 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.TagType;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagDouble
extends AbstractTag {
protected double value;
public TagDouble(@Nonnull String name, double value) {
super(name);
this.setValue(value);
}
public TagDouble(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
this.setValue(inputStream.readDouble());
}
@Override
public byte getTagID() {
return TagType.DOUBLE.typeID;
}
public double getValue() {
return this.value;
}
public void setValue(double d) {
this.value = d;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.writeDouble(this.value);
}
}

View file

@ -0,0 +1,45 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.TagType;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagFloat
extends AbstractTag {
protected float value;
public TagFloat(@Nonnull String name, float value) {
super(name);
this.setValue(value);
}
public TagFloat(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
this.setValue(inputStream.readFloat());
}
@Override
public byte getTagID() {
return TagType.FLOAT.typeID;
}
public float getValue() {
return this.value;
}
public void setValue(float f) {
this.value = f;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.writeFloat(this.value);
}
}

View file

@ -0,0 +1,45 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.TagType;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagInteger
extends AbstractTag {
protected int value;
public TagInteger(@Nonnull String name, int value) {
super(name);
this.setValue(value);
}
public TagInteger(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
this.setValue(inputStream.readInt());
}
@Override
public byte getTagID() {
return TagType.INTEGER.typeID;
}
public int getValue() {
return this.value;
}
public void setValue(int i) {
this.value = i;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.writeInt(this.value);
}
}

View file

@ -0,0 +1,55 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.TagType;
import com.google.common.base.Preconditions;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagIntegerArray
extends AbstractTag {
protected int[] values;
public TagIntegerArray(@Nonnull String name, @Nonnull int[] values) {
super(name);
this.setValues(values);
}
public TagIntegerArray(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
int size = inputStream.readInt();
int[] data = new int[size];
for (int i = 0; i < size; ++i) {
data[i] = inputStream.readInt();
}
this.values = data;
}
@Override
public byte getTagID() {
return TagType.INTEGER_ARRAY.typeID;
}
public int[] getValues() {
return this.values;
}
public void setValues(@Nonnull int[] i) {
Preconditions.checkNotNull(i, "i");
this.values = i;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.writeInt(this.values.length);
for (int i : this.values) {
outputStream.writeInt(i);
}
}
}

View file

@ -0,0 +1,96 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.error.UnexpectedTagTypeException;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.IAnonymousTagContainer;
import com.evilco.mc.nbt.tag.ITag;
import com.evilco.mc.nbt.tag.TagType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
public class TagList
extends AbstractTag
implements IAnonymousTagContainer {
protected List<ITag> tagList;
public TagList(@Nonnull String name) {
super(name);
this.tagList = new ArrayList<ITag>();
}
public TagList(@Nonnull String name, @Nonnull List<ITag> tagList) {
super(name);
Preconditions.checkNotNull(tagList, "tagList");
this.tagList = tagList;
}
public TagList(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
this.tagList = new ArrayList<ITag>();
byte type = inputStream.readByte();
TagType tagType = TagType.valueOf(type);
int size = inputStream.readInt();
if (tagType == TagType.END) {
return;
}
for (int i = 0; i < size; ++i) {
this.addTag(inputStream.readTag(tagType, true));
}
}
@Override
public void addTag(@Nonnull ITag tag) {
this.tagList.add(tag);
}
@Override
public List<ITag> getTags() {
return ((ImmutableList.Builder)new ImmutableList.Builder().addAll(this.tagList)).build();
}
@Override
public <T extends ITag> List<T> getTags(Class<T> tagClass) throws UnexpectedTagTypeException {
ImmutableList.Builder builder = new ImmutableList.Builder();
for (ITag tag : this.tagList) {
if (!tagClass.isInstance(tag)) {
throw new UnexpectedTagTypeException("The list entry should be of type " + tagClass.getSimpleName() + ", but is of type " + tag.getClass().getSimpleName());
}
builder.add(tag);
}
return builder.build();
}
@Override
public byte getTagID() {
return TagType.LIST.typeID;
}
@Override
public void removeTag(@Nonnull ITag tag) {
this.tagList.remove(tag);
}
@Override
public void setTag(int i, @Nonnull ITag tag) {
this.tagList.set(i, tag);
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.writeByte(this.tagList.size() > 0 ? this.tagList.get(0).getTagID() : TagType.END.typeID);
outputStream.writeInt(this.tagList.size());
for (ITag tag : this.tagList) {
tag.write(outputStream, true);
}
}
}

View file

@ -0,0 +1,45 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.TagType;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagLong
extends AbstractTag {
protected long value;
public TagLong(@Nonnull String name, long value) {
super(name);
this.setValue(value);
}
public TagLong(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
this.setValue(inputStream.readLong());
}
@Override
public byte getTagID() {
return TagType.LONG.typeID;
}
public long getValue() {
return this.value;
}
public void setValue(long l) {
this.value = l;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.writeLong(this.value);
}
}

View file

@ -0,0 +1,45 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.TagType;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagShort
extends AbstractTag {
protected short value;
public TagShort(@Nonnull String name, short value) {
super(name);
this.setValue(value);
}
public TagShort(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
this.setValue(inputStream.readShort());
}
@Override
public byte getTagID() {
return TagType.SHORT.typeID;
}
public short getValue() {
return this.value;
}
public void setValue(short s) {
this.value = s;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
outputStream.writeShort(this.value);
}
}

View file

@ -0,0 +1,51 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.evilco.mc.nbt.tag.AbstractTag;
import com.evilco.mc.nbt.tag.ITag;
import com.evilco.mc.nbt.tag.TagType;
import java.io.IOException;
import javax.annotation.Nonnull;
public class TagString
extends AbstractTag {
protected String value;
public TagString(@Nonnull String name, @Nonnull String value) {
super(name);
this.setValue(value);
}
public TagString(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
super(inputStream, anonymous);
short size = inputStream.readShort();
byte[] data = new byte[size];
inputStream.readFully(data);
this.setValue(new String(data, ITag.STRING_CHARSET));
}
@Override
public byte getTagID() {
return TagType.STRING.typeID;
}
public String getValue() {
return this.value;
}
public void setValue(@Nonnull String s) {
this.value = s;
}
@Override
public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
super.write(outputStream, anonymous);
byte[] outputBytes = this.value.getBytes(ITag.STRING_CHARSET);
outputStream.writeShort(outputBytes.length);
outputStream.write(outputBytes);
}
}

View file

@ -0,0 +1,55 @@
/*
* Decompiled with CFR 0.152.
*/
package com.evilco.mc.nbt.tag;
import com.evilco.mc.nbt.tag.ITag;
import com.evilco.mc.nbt.tag.TagByte;
import com.evilco.mc.nbt.tag.TagByteArray;
import com.evilco.mc.nbt.tag.TagCompound;
import com.evilco.mc.nbt.tag.TagDouble;
import com.evilco.mc.nbt.tag.TagFloat;
import com.evilco.mc.nbt.tag.TagInteger;
import com.evilco.mc.nbt.tag.TagIntegerArray;
import com.evilco.mc.nbt.tag.TagList;
import com.evilco.mc.nbt.tag.TagLong;
import com.evilco.mc.nbt.tag.TagShort;
import com.evilco.mc.nbt.tag.TagString;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
public enum TagType {
BYTE(1, TagByte.class),
BYTE_ARRAY(7, TagByteArray.class),
COMPOUND(10, TagCompound.class),
DOUBLE(6, TagDouble.class),
END(0, null),
FLOAT(5, TagFloat.class),
INTEGER(3, TagInteger.class),
INTEGER_ARRAY(11, TagIntegerArray.class),
LIST(9, TagList.class),
LONG(4, TagLong.class),
SHORT(2, TagShort.class),
STRING(8, TagString.class);
protected static final Map<Byte, TagType> typeMap;
public final Class<? extends ITag> tagType;
public final byte typeID;
private TagType(int typeID, Class<? extends ITag> type) {
this.typeID = (byte)typeID;
this.tagType = type;
}
public static TagType valueOf(byte typeID) {
return typeMap.get(typeID);
}
static {
ImmutableMap.Builder<Byte, TagType> mapBuilder = new ImmutableMap.Builder<Byte, TagType>();
for (TagType type : TagType.values()) {
mapBuilder.put(type.typeID, type);
}
typeMap = mapBuilder.build();
}
}

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());
}
}
}

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