Add Override annotations where appropriate

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2019-04-28 11:38:01 +10:00
parent c7281b2159
commit bfea9a3269
140 changed files with 1021 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import java.io.File;
import java.io.FilenameFilter;
public class DatFileFilter implements FilenameFilter {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".dat");
}

View File

@@ -7,54 +7,67 @@ import java.util.Set;
public abstract class LazyHashSet<E> implements Set<E> {
Set<E> reference = null;
@Override
public int size() {
return getReference().size();
}
@Override
public boolean isEmpty() {
return getReference().isEmpty();
}
@Override
public boolean contains(Object o) {
return getReference().contains(o);
}
@Override
public Iterator<E> iterator() {
return getReference().iterator();
}
@Override
public Object[] toArray() {
return getReference().toArray();
}
@Override
public <T> T[] toArray(T[] a) {
return getReference().toArray(a);
}
@Override
public boolean add(E o) {
return getReference().add(o);
}
@Override
public boolean remove(Object o) {
return getReference().remove(o);
}
@Override
public boolean containsAll(Collection<?> c) {
return getReference().containsAll(c);
}
@Override
public boolean addAll(Collection<? extends E> c) {
return getReference().addAll(c);
}
@Override
public boolean retainAll(Collection<?> c) {
return getReference().retainAll(c);
}
@Override
public boolean removeAll(Collection<?> c) {
return getReference().removeAll(c);
}
@Override
public void clear() {
getReference().clear();
}

View File

@@ -21,6 +21,7 @@ public class TerminalConsoleWriterThread extends Thread {
this.setDaemon(true);
}
@Override
public void run() {
String message;

View File

@@ -43,6 +43,7 @@ public class UnsafeList<E> extends AbstractList<E> implements List<E>, RandomAcc
this(32);
}
@Override
public E get(int index) {
rangeCheck(index);
@@ -53,6 +54,7 @@ public class UnsafeList<E> extends AbstractList<E> implements List<E>, RandomAcc
return (E) data[index];
}
@Override
public E set(int index, E element) {
rangeCheck(index);
@@ -61,12 +63,14 @@ public class UnsafeList<E> extends AbstractList<E> implements List<E>, RandomAcc
return old;
}
@Override
public boolean add(E element) {
growIfNeeded();
data[size++] = element;
return true;
}
@Override
public void add(int index, E element) {
growIfNeeded();
System.arraycopy(data, index, data, index + 1, size - index);
@@ -74,6 +78,7 @@ public class UnsafeList<E> extends AbstractList<E> implements List<E>, RandomAcc
size++;
}
@Override
public E remove(int index) {
rangeCheck(index);
@@ -87,6 +92,7 @@ public class UnsafeList<E> extends AbstractList<E> implements List<E>, RandomAcc
return old;
}
@Override
public boolean remove(Object o) {
int index = indexOf(o);
if (index >= 0) {
@@ -97,6 +103,7 @@ public class UnsafeList<E> extends AbstractList<E> implements List<E>, RandomAcc
return false;
}
@Override
public int indexOf(Object o) {
for (int i = 0; i < size; i++) {
if (o == data[i] || o.equals(data[i])) {
@@ -107,10 +114,12 @@ public class UnsafeList<E> extends AbstractList<E> implements List<E>, RandomAcc
return -1;
}
@Override
public boolean contains(Object o) {
return indexOf(o) >= 0;
}
@Override
public void clear() {
// Create new array to reset memory usage to initial capacity
size = 0;
@@ -134,14 +143,17 @@ public class UnsafeList<E> extends AbstractList<E> implements List<E>, RandomAcc
}
}
@Override
public int size() {
return size;
}
@Override
public boolean isEmpty() {
return size == 0;
}
@Override
public Object clone() throws CloneNotSupportedException {
UnsafeList<E> copy = (UnsafeList<E>) super.clone();
copy.data = Arrays.copyOf(data, size);
@@ -154,6 +166,7 @@ public class UnsafeList<E> extends AbstractList<E> implements List<E>, RandomAcc
return copy;
}
@Override
public Iterator<E> iterator() {
// Try to find an iterator that isn't in use
for (Iterator iter : iterPool) {
@@ -233,11 +246,13 @@ public class UnsafeList<E> extends AbstractList<E> implements List<E>, RandomAcc
valid = true;
}
@Override
public boolean hasNext() {
valid = index != size;
return valid;
}
@Override
public E next() {
if (modCount != expectedModCount) {
throw new ConcurrentModificationException();
@@ -256,6 +271,7 @@ public class UnsafeList<E> extends AbstractList<E> implements List<E>, RandomAcc
return (E) data[lastRet = i];
}
@Override
public void remove() {
if (lastRet < 0) {
throw new IllegalStateException();

View File

@@ -13,6 +13,7 @@ public abstract class Waitable<T> implements Runnable {
T value = null;
Status status = Status.WAITING;
@Override
public final void run() {
synchronized (this) {
if (status != Status.WAITING) {

View File

@@ -15,11 +15,13 @@ public final class WeakCollection<T> implements Collection<T> {
collection = new ArrayList<WeakReference<T>>();
}
@Override
public boolean add(T value) {
Validate.notNull(value, "Cannot add null value");
return collection.add(new WeakReference<T>(value));
}
@Override
public boolean addAll(Collection<? extends T> collection) {
Collection<WeakReference<T>> values = this.collection;
boolean ret = false;
@@ -30,10 +32,12 @@ public final class WeakCollection<T> implements Collection<T> {
return ret;
}
@Override
public void clear() {
collection.clear();
}
@Override
public boolean contains(Object object) {
if (object == null) {
return false;
@@ -46,19 +50,23 @@ public final class WeakCollection<T> implements Collection<T> {
return false;
}
@Override
public boolean containsAll(Collection<?> collection) {
return toCollection().containsAll(collection);
}
@Override
public boolean isEmpty() {
return !iterator().hasNext();
}
@Override
public Iterator<T> iterator() {
return new Iterator<T>() {
Iterator<WeakReference<T>> it = collection.iterator();
Object value = NO_VALUE;
@Override
public boolean hasNext() {
Object value = this.value;
if (value != null && value != NO_VALUE) {
@@ -81,6 +89,7 @@ public final class WeakCollection<T> implements Collection<T> {
return false;
}
@Override
public T next() throws NoSuchElementException {
if (!hasNext()) {
throw new NoSuchElementException("No more elements");
@@ -92,6 +101,7 @@ public final class WeakCollection<T> implements Collection<T> {
return value;
}
@Override
public void remove() throws IllegalStateException {
if (value != NO_VALUE) {
throw new IllegalStateException("No last element");
@@ -103,6 +113,7 @@ public final class WeakCollection<T> implements Collection<T> {
};
}
@Override
public boolean remove(Object object) {
if (object == null) {
return false;
@@ -118,6 +129,7 @@ public final class WeakCollection<T> implements Collection<T> {
return false;
}
@Override
public boolean removeAll(Collection<?> collection) {
Iterator<T> it = this.iterator();
boolean ret = false;
@@ -130,6 +142,7 @@ public final class WeakCollection<T> implements Collection<T> {
return ret;
}
@Override
public boolean retainAll(Collection<?> collection) {
Iterator<T> it = this.iterator();
boolean ret = false;
@@ -142,6 +155,7 @@ public final class WeakCollection<T> implements Collection<T> {
return ret;
}
@Override
public int size() {
int s = 0;
for (T value : this) {
@@ -150,10 +164,12 @@ public final class WeakCollection<T> implements Collection<T> {
return s;
}
@Override
public Object[] toArray() {
return this.toArray(new Object[0]);
}
@Override
public <T> T[] toArray(T[] array) {
return toCollection().toArray(array);
}