Hopefully fixed java 8 Optional errors

This commit is contained in:
Jared committed 2016-10-30 22:35:44 +02:00
1 parent c6643a65d9
commit e20b304083
6 files changed
+138 -153

No files matched your search

@@ -70,10 +70,6 @@ public class IngredientAnyAdvanced implements IIngredient {
@Override
public boolean matches(IItemStack item) {
// TODO: what is the point of this?
if (!item.matches(item))
return false;
for (IItemCondition condition : conditions) {
if (!condition.matches(item))
return false;
@@ -84,10 +80,6 @@ public class IngredientAnyAdvanced implements IIngredient {
@Override
public boolean matchesExact(IItemStack item) {
// TODO: what is the point of this?
if (!item.matchesExact(item))
return false;
for (IItemCondition condition : conditions) {
if (!condition.matches(item))
return false;
@@ -11,85 +11,75 @@ import java.io.IOException;
import java.util.Iterator;
/**
*
* @author Stan
*/
public class CloseablePriorityList<T> implements Iterable<T> {
private CloseableEntry first;
private CloseableEntry first;
/**
* Adds a new item to the list. The new item will be inserted at the head of
* the list.
*
* @param value
* @return
*/
public Closeable add(T value) {
if (first == null) {
first = new CloseableEntry(value);
} else {
CloseableEntry entry = new CloseableEntry(value);
entry.next = first;
first.prev = entry;
first = entry;
}
/**
* Adds a new item to the list. The new item will be inserted at the head of
* the list.
*
* @param value
* @return
*/
public Closeable add(T value) {
if(first == null) {
first = new CloseableEntry(value);
} else {
CloseableEntry entry = new CloseableEntry(value);
entry.next = first;
first.prev = entry;
first = entry;
}
return first;
}
return first;
}
@Override
public Iterator<T> iterator() {
return new MyIterator();
}
@Override
public Iterator<T> iterator() {
return new MyIterator();
}
private class MyIterator implements Iterator<T> {
private CloseableEntry current = null;
private class MyIterator implements Iterator<T> {
private CloseableEntry current = null;
@Override
public boolean hasNext() {
return current == null || current.next != null;
}
@Override
public boolean hasNext() {
return current == null || current.next != null;
}
@Override
public T next() {
current = current == null ? first : current.next;
return current.value;
}
@Override
public T next() {
current = current == null ? first : current.next;
return current.value;
}
@Override
public void remove() {
throw new UnsupportedOperationException("Not supported yet."); // To
// change
// body
// of
// generated
// methods,
// choose
// Tools
// |
// Templates.
}
}
@Override
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
private class CloseableEntry implements Closeable {
private final T value;
private CloseableEntry next;
private CloseableEntry prev;
private class CloseableEntry implements Closeable {
private final T value;
private CloseableEntry next;
private CloseableEntry prev;
public CloseableEntry(T value) {
this.value = value;
}
public CloseableEntry(T value) {
this.value = value;
}
@Override
public void close() throws IOException {
if (next != null) {
next.prev = prev;
}
if (prev == null) {
first = next;
} else {
prev.next = next;
}
}
}
@Override
public void close() throws IOException {
if(next != null) {
next.prev = prev;
}
if(prev == null) {
first = next;
} else {
prev.next = next;
}
}
}
}