Code cleaning

Most notable change: Remove redundant type parameters and replaced with <>. This is a small step to bring us closer to upstream parity.
This commit is contained in:
matt
2019-02-15 21:46:10 -05:00
parent 3236bdd78e
commit 85bfd16d7c
82 changed files with 1417 additions and 1406 deletions

View File

@ -378,7 +378,7 @@ public class FaweAPI {
});
RegionWrapper bounds = new RegionWrapper(origin.x - radius, origin.x + radius, origin.z - radius, origin.z + radius);
RegionWrapper boundsPlus = new RegionWrapper(bounds.minX - 64, bounds.maxX + 512, bounds.minZ - 64, bounds.maxZ + 512);
HashSet<RegionWrapper> regionSet = new HashSet<RegionWrapper>(Arrays.asList(bounds));
HashSet<RegionWrapper> regionSet = new HashSet<>(Arrays.asList(bounds));
ArrayList<DiskStorageHistory> result = new ArrayList<>();
for (File file : files) {
UUID uuid = UUID.fromString(file.getParentFile().getName());

View File

@ -76,7 +76,7 @@ public class FaweCache {
}
public static Map<String, Object> asMap(Object... pairs) {
HashMap<String, Object> map = new HashMap<String, Object>(pairs.length >> 1);
HashMap<String, Object> map = new HashMap<>(pairs.length >> 1);
for (int i = 0; i < pairs.length; i += 2) {
String key = (String) pairs[i];
Object value = pairs[i + 1];

View File

@ -33,9 +33,9 @@ public final class TypeDescription {
public TypeDescription(Class<? extends Object> clazz, Tag tag) {
this.type = clazz;
this.tag = tag;
listProperties = new HashMap<String, Class<? extends Object>>();
keyProperties = new HashMap<String, Class<? extends Object>>();
valueProperties = new HashMap<String, Class<? extends Object>>();
listProperties = new HashMap<>();
keyProperties = new HashMap<>();
valueProperties = new HashMap<>();
}
public TypeDescription(Class<? extends Object> clazz, String tag) {

View File

@ -175,7 +175,7 @@ public class Yaml {
* @return YAML String
*/
public String dump(Object data) {
List<Object> list = new ArrayList<Object>(1);
List<Object> list = new ArrayList<>(1);
list.add(data);
return dumpAll(list.iterator());
}
@ -215,7 +215,7 @@ public class Yaml {
* stream to write to
*/
public void dump(Object data, Writer output) {
List<Object> list = new ArrayList<Object>(1);
List<Object> list = new ArrayList<>(1);
list.add(data);
dumpAll(list.iterator(), output, null);
}
@ -292,7 +292,7 @@ public class Yaml {
if (flowStyle != null) {
representer.setDefaultFlowStyle(flowStyle);
}
List<Object> list = new ArrayList<Object>(1);
List<Object> list = new ArrayList<>(1);
list.add(data);
StringWriter buffer = new StringWriter();
dumpAll(list.iterator(), buffer, rootTag);
@ -345,7 +345,7 @@ public class Yaml {
}
private static class SilentEmitter implements Emitable {
private List<Event> events = new ArrayList<Event>(100);
private List<Event> events = new ArrayList<>(100);
public List<Event> getEvents() {
return events;

View File

@ -16,7 +16,7 @@ public class ConfigurationSerialization {
public static final String SERIALIZED_TYPE_KEY = "==";
private static final Map<String, Class<? extends ConfigurationSerializable>> aliases =
new HashMap<String, Class<? extends ConfigurationSerializable>>();
new HashMap<>();
private final Class<? extends ConfigurationSerializable> clazz;
protected ConfigurationSerialization(Class<? extends ConfigurationSerializable> clazz) {

View File

@ -163,7 +163,7 @@ public abstract class IntFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
@Override
public Map<Short, CompoundTag> getTiles() {
return tiles == null ? new HashMap<Short, CompoundTag>() : tiles;
return tiles == null ? new HashMap<>() : tiles;
}
@Override
@ -189,7 +189,7 @@ public abstract class IntFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
@Override
public HashSet<UUID> getEntityRemoves() {
return entityRemoves == null ? new HashSet<UUID>() : entityRemoves;
return entityRemoves == null ? new HashSet<>() : entityRemoves;
}
@Override

View File

@ -123,7 +123,7 @@ public class WeakFaweQueueMap implements IFaweQueueMap {
@Override
public void add(FaweChunk chunk) {
long pair = MathMan.pairInt(chunk.getX(), chunk.getZ());
Reference<FaweChunk> previous = this.blocks.put(pair, new SoftReference<FaweChunk>(chunk));
Reference<FaweChunk> previous = this.blocks.put(pair, new SoftReference<>(chunk));
if (previous != null) {
FaweChunk previousChunk = previous.get();
if (previousChunk != null) {

View File

@ -406,7 +406,7 @@ public class JSON2NBT {
}
public Tag parse() throws NBTException {
HashMap<String, Tag> map = new HashMap<String, Tag>();
HashMap<String, Tag> map = new HashMap<>();
Iterator var2 = this.tagList.iterator();
while (var2.hasNext()) {

View File

@ -102,12 +102,13 @@ public class MCAChunk extends FaweChunk<Void> {
if (entities.isEmpty()) {
out.writeNamedEmptyList("Entities");
} else {
out.writeNamedTag("Entities", new ListTag(CompoundTag.class, new ArrayList<CompoundTag>(entities.values())));
out.writeNamedTag("Entities", new ListTag(CompoundTag.class, new ArrayList<>(entities.values())));
}
if (tiles.isEmpty()) {
out.writeNamedEmptyList("TileEntities");
} else {
out.writeNamedTag("TileEntities", new ListTag(CompoundTag.class, new ArrayList<CompoundTag>(tiles.values())));
out.writeNamedTag("TileEntities", new ListTag(CompoundTag.class,
new ArrayList<>(tiles.values())));
}
out.writeNamedTag("InhabitedTime", inhabitedTime);
out.writeNamedTag("LastUpdate", lastUpdate);
@ -422,9 +423,9 @@ public class MCAChunk extends FaweChunk<Void> {
return null;
}
// e.g. by precalculating the length
HashMap<String, Object> level = new HashMap<String, Object>();
level.put("Entities", new ListTag(CompoundTag.class, new ArrayList<CompoundTag>(entities.values())));
level.put("TileEntities", new ListTag(CompoundTag.class, new ArrayList<CompoundTag>(tiles.values())));
HashMap<String, Object> level = new HashMap<>();
level.put("Entities", new ListTag(CompoundTag.class, new ArrayList<>(entities.values())));
level.put("TileEntities", new ListTag(CompoundTag.class, new ArrayList<>(tiles.values())));
level.put("InhabitedTime", inhabitedTime);
level.put("LastUpdate", lastUpdate);
level.put("LightPopulated", (byte) 0);
@ -442,7 +443,7 @@ public class MCAChunk extends FaweChunk<Void> {
if (idLayer == null) {
continue;
}
HashMap<String, Object> map = new HashMap<String, Object>();
HashMap<String, Object> map = new HashMap<>();
map.put("Y", (byte) layer);
map.put("BlockLight", blockLight[layer]);
map.put("SkyLight", skyLight[layer]);
@ -499,7 +500,7 @@ public class MCAChunk extends FaweChunk<Void> {
@Override
public void accept(Integer index, CompoundTag entityTag) {
if (entities == null) {
entities = new HashMap<UUID, CompoundTag>();
entities = new HashMap<>();
}
long least = entityTag.getLong("UUIDLeast");
long most = entityTag.getLong("UUIDMost");
@ -635,7 +636,7 @@ public class MCAChunk extends FaweChunk<Void> {
@Override
public Map<Short, CompoundTag> getTiles() {
return tiles == null ? new HashMap<Short, CompoundTag>() : tiles;
return tiles == null ? new HashMap<>() : tiles;
}
@Override

View File

@ -21,7 +21,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
private int x, z;
public static int HEIGHT = 256;
private final ArrayDeque<Runnable> tasks = new ArrayDeque<Runnable>(0);
private final ArrayDeque<Runnable> tasks = new ArrayDeque<>(0);
/**
* A FaweSections object represents a chunk and the blocks that you wish to change in it.

View File

@ -97,7 +97,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
}
private List<? extends Entity> wrapEntities(final List<? extends Entity> entities) {
final List<Entity> newList = new ArrayList<Entity>(entities.size());
final List<Entity> newList = new ArrayList<>(entities.size());
for (final Entity entity : entities) {
newList.add(new TrackedEntity(entity));
}

View File

@ -121,7 +121,7 @@ public class SplineBrush implements Brush, ResettableTool {
double continuity = 0;
double quality = 10;
final List<Node> nodes = new ArrayList<Node>(centroids.size());
final List<Node> nodes = new ArrayList<>(centroids.size());
for (final Vector3 nodevector : centroids) {
final Node n = new Node(nodevector);

View File

@ -491,7 +491,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
public Map<Integer, Double> getPercents() {
Map<Integer, Integer> map = getBlocks();
int count = getSize();
Int2ObjectOpenHashMap<Double> newMap = new Int2ObjectOpenHashMap<Double>();
Int2ObjectOpenHashMap<Double> newMap = new Int2ObjectOpenHashMap<>();
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
int id = entry.getKey();
int changes = entry.getValue();

View File

@ -12,7 +12,7 @@ import java.util.concurrent.ConcurrentLinkedDeque;
public abstract class IterableThreadLocal<T> extends ThreadLocal<T> implements Iterable<T> {
private ThreadLocal<T> flag;
private ConcurrentLinkedDeque<T> allValues = new ConcurrentLinkedDeque<T>();
private ConcurrentLinkedDeque<T> allValues = new ConcurrentLinkedDeque<>();
public IterableThreadLocal() {
}

View File

@ -7,7 +7,7 @@ import java.util.TreeMap;
public class SimpleRandomCollection<E> extends RandomCollection<E> {
private final NavigableMap<Double, E> map = new TreeMap<Double, E>();
private final NavigableMap<Double, E> map = new TreeMap<>();
private double total = 0;
public SimpleRandomCollection(Map<E, Double> weights, SimpleRandom random) {

View File

@ -93,10 +93,10 @@ public class SoftHashMap<K, V> implements Map<K, V> {
public SoftHashMap(int retentionSize) {
super();
RETENTION_SIZE = Math.max(0, retentionSize);
queue = new ReferenceQueue<V>();
queue = new ReferenceQueue<>();
strongReferencesLock = new ReentrantLock();
map = new ConcurrentHashMap<K, SoftValue<V, K>>();
strongReferences = new ConcurrentLinkedQueue<V>();
map = new ConcurrentHashMap<>();
strongReferences = new ConcurrentLinkedQueue<>();
}
/**
@ -223,7 +223,7 @@ public class SoftHashMap<K, V> implements Map<K, V> {
//noinspection unchecked
return Collections.EMPTY_SET;
}
Collection<V> values = new ArrayList<V>(keys.size());
Collection<V> values = new ArrayList<>(keys.size());
for (K key : keys) {
V v = get(key);
if (v != null) {
@ -238,7 +238,7 @@ public class SoftHashMap<K, V> implements Map<K, V> {
*/
public V put(K key, V value) {
processQueue(); // throw out garbage collected values first
SoftValue<V, K> sv = new SoftValue<V, K>(value, key, queue);
SoftValue<V, K> sv = new SoftValue<>(value, key, queue);
SoftValue<V, K> previous = map.put(key, sv);
addToStrongReferences(value);
return previous != null ? previous.get() : null;
@ -274,7 +274,7 @@ public class SoftHashMap<K, V> implements Map<K, V> {
return Collections.EMPTY_SET;
}
Map<K, V> kvPairs = new HashMap<K, V>(keys.size());
Map<K, V> kvPairs = new HashMap<>(keys.size());
for (K key : keys) {
V v = get(key);
if (v != null) {
@ -307,4 +307,4 @@ public class SoftHashMap<K, V> implements Map<K, V> {
}
}
}
}

View File

@ -39,7 +39,7 @@ public class PGZIPOutputStream extends FilterOutputStream {
// todo: remove after block guessing is implemented
// array list that contains the block sizes
ArrayList<Integer> blockSizes = new ArrayList<Integer>();
ArrayList<Integer> blockSizes = new ArrayList<>();
private int level = Deflater.DEFAULT_COMPRESSION;
private int strategy = Deflater.DEFAULT_STRATEGY;
@ -80,7 +80,7 @@ public class PGZIPOutputStream extends FilterOutputStream {
super(out);
this.executor = executor;
this.nthreads = nthreads;
this.emitQueue = new ArrayBlockingQueue<Future<byte[]>>(nthreads);
this.emitQueue = new ArrayBlockingQueue<>(nthreads);
writeHeader();
}
@ -246,4 +246,4 @@ public class PGZIPOutputStream extends FilterOutputStream {
// LOG.warn("Already closed.");
}
}
}
}

View File

@ -38,17 +38,17 @@ public class PolyhedralRegion extends AbstractRegion {
/**
* Vertices that are contained in the convex hull.
*/
private final Set<BlockVector3> vertices = new LinkedHashSet<BlockVector3>();
private final Set<BlockVector3> vertices = new LinkedHashSet<>();
/**
* Triangles that form the convex hull.
*/
private final List<Triangle> triangles = new ArrayList<Triangle>();
private final List<Triangle> triangles = new ArrayList<>();
/**
* Vertices that are coplanar to the first 3 vertices.
*/
private final Set<BlockVector3> vertexBacklog = new LinkedHashSet<BlockVector3>();
private final Set<BlockVector3> vertexBacklog = new LinkedHashSet<>();
/**
* Minimum point of the axis-aligned bounding box.
@ -165,7 +165,7 @@ public class PolyhedralRegion extends AbstractRegion {
triangles.add((new Triangle(v[0], v[size - 1], v[size - 2])));
return true;
}
final Set<Edge> borderEdges = new LinkedHashSet<Edge>();
final Set<Edge> borderEdges = new LinkedHashSet<>();
for (Iterator<Triangle> it = triangles.iterator(); it.hasNext(); ) {
final Triangle triangle = it.next();
@ -200,7 +200,7 @@ public class PolyhedralRegion extends AbstractRegion {
vertices.remove(vertex);
// Clone, clear and work through the backlog
final List<BlockVector3> vertexBacklog2 = new ArrayList<BlockVector3>(vertexBacklog);
final List<BlockVector3> vertexBacklog2 = new ArrayList<>(vertexBacklog);
vertexBacklog.clear();
for (BlockVector3 vertex2 : vertexBacklog2) {
addVertex(vertex2);
@ -261,7 +261,7 @@ public class PolyhedralRegion extends AbstractRegion {
}
private static void shiftCollection(Collection<BlockVector3> collection, BlockVector3 change) {
final List<BlockVector3> tmp = new ArrayList<BlockVector3>(collection);
final List<BlockVector3> tmp = new ArrayList<>(collection);
collection.clear();
for (BlockVector3 vertex : tmp) {
collection.add(change.add(vertex));
@ -308,7 +308,7 @@ public class PolyhedralRegion extends AbstractRegion {
return vertices;
}
final List<BlockVector3> ret = new ArrayList<BlockVector3>(vertices);
final List<BlockVector3> ret = new ArrayList<>(vertices);
ret.addAll(vertexBacklog);
return ret;
@ -322,4 +322,4 @@ public class PolyhedralRegion extends AbstractRegion {
public AbstractRegion clone() {
return new PolyhedralRegion(this);
}
}
}

View File

@ -152,7 +152,7 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio
@Override
public List<String> getInformationLines() {
final List<String> lines = new ArrayList<String>();
final List<String> lines = new ArrayList<>();
for (int i = 0; i < positions.size(); i++) {
lines.add("Position " + i + ": " + positions.get(i));
}

View File

@ -146,7 +146,7 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion {
@Override
public List<String> getInformationLines() {
List<String> ret = new ArrayList<String>();
List<String> ret = new ArrayList<>();
ret.add("Vertices: " + region.getVertices().size());
ret.add("Triangles: " + region.getTriangles().size());
@ -202,7 +202,7 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion {
Collection<BlockVector3> vertices = region.getVertices();
Collection<Triangle> triangles = region.getTriangles();
Map<BlockVector3, Integer> vertexIds = new HashMap<BlockVector3, Integer>(vertices.size());
Map<BlockVector3, Integer> vertexIds = new HashMap<>(vertices.size());
int lastVertexId = -1;
for (BlockVector3 vertex : vertices) {
vertexIds.put(vertex, ++lastVertexId);

View File

@ -228,7 +228,7 @@ public class SetQueue {
}
public Collection<FaweQueue> getAllQueues() {
ArrayList<FaweQueue> list = new ArrayList<FaweQueue>(activeQueues.size() + inactiveQueues.size());
ArrayList<FaweQueue> list = new ArrayList<>(activeQueues.size() + inactiveQueues.size());
list.addAll(inactiveQueues);
list.addAll(activeQueues);
return list;

View File

@ -167,7 +167,7 @@ public class ShapeInterpolator {
bezierCoordinates[0] = curX = movX = coordinates[0];
bezierCoordinates[1] = curY = movY = coordinates[1];
float newX, newY;
final Vector<Point2D.Float> savedPathEndPoints = new Vector<Point2D.Float>();
final Vector<Point2D.Float> savedPathEndPoints = new Vector<>();
numCoordinates = 2;
while (!pi.isDone()) {
switch (pi.currentSegment(coordinates)) {
@ -735,4 +735,4 @@ public class ShapeInterpolator {
return res;
}
}
}
}

View File

@ -148,7 +148,7 @@ public class StringMan {
}
public static List<String> split(String input, char delim) {
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<>();
int start = 0;
int bracket = 0;
boolean inQuotes = false;

View File

@ -583,7 +583,7 @@ public class TextureUtil implements TextureHolder{
// Get all the groups in the current jar
// The vanilla textures are in `assets/minecraft`
// A jar may contain textures for multiple mods
Set<String> mods = new HashSet<String>();
Set<String> mods = new HashSet<>();
{
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {

View File

@ -57,7 +57,7 @@ public class UsageMessage extends Message {
text(BBC.HELP_HEADER_SUBCOMMANDS.f());
String prefix = !commandString.isEmpty() ? commandString + " " : "";
List<CommandMapping> list = new ArrayList<CommandMapping>(dispatcher.getCommands());
List<CommandMapping> list = new ArrayList<>(dispatcher.getCommands());
Collections.sort(list, new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN));
for (CommandMapping mapping : list) {

View File

@ -308,7 +308,7 @@ public class TaskBuilder extends Metadatable {
continue;
case SYNC_PARALLEL:
case ASYNC_PARALLEL:
final ArrayList<RunnableTask> parallel = new ArrayList<RunnableTask>();
final ArrayList<RunnableTask> parallel = new ArrayList<>();
parallel.add(task);
RunnableTask next = tasks.peek();
while (next != null && next.type == task.type) {
@ -571,4 +571,4 @@ public class TaskBuilder extends Metadatable {
DELAY,
ABORT
}
}
}