Merge pull request #2759 from sotovdev/master

We can't invoke equals method on object that can be null
This commit is contained in:
LevelX2 2017-01-11 07:33:54 +01:00 committed by GitHub
commit 0e9b46bdc1
13 changed files with 23 additions and 43 deletions

View file

@ -16,7 +16,7 @@ public class ExpansionInfo {
@DatabaseField(unique = true)
protected String name;
@DatabaseField(unique = true)
@DatabaseField(id = true,unique = true)
protected String code;
@DatabaseField
protected String blockName;

View file

@ -132,6 +132,6 @@ public class TargetSpell extends TargetObject {
private boolean canBeChosen(StackObject stackObject, UUID sourceID, UUID sourceControllerId, Game game) {
return stackObject instanceof Spell
&& game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getControllerId())
&& filter.match((Spell) stackObject, sourceID, sourceControllerId, game);
&& filter.match(stackObject, sourceID, sourceControllerId, game);
}
}

View file

@ -28,7 +28,6 @@
package mage.target.common;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.UUID;

View file

@ -56,16 +56,6 @@ public class TargetOpponent extends TargetPlayer {
super(target);
}
@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
return super.canChoose(sourceId, sourceControllerId, game);
}
@Override
public boolean canTarget(UUID id, Ability source, Game game) {
return super.canTarget(id, source, game);
}
@Override
public TargetOpponent copy() {
return new TargetOpponent(this);

View file

@ -69,7 +69,7 @@ public class CardUtil {
private static final String SOURCE_EXILE_ZONE_TEXT = "SourceExileZone";
static String numberStrings[] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
static final String[] numberStrings = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "ninteen", "twenty"};
public static final String[] NON_CHANGELING_SUBTYPES_VALUES = new String[]{

View file

@ -45,7 +45,7 @@ import java.util.concurrent.locks.ReentrantLock;
public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
//TODO: might have to make E extend Copyable
protected List<E> list = new ArrayList<>();
protected final List<E> list = new ArrayList<>();
protected final ReentrantLock lock = new ReentrantLock();
@ -357,8 +357,8 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
private class CircularIterator<E> implements Iterator<E> {
int cursor;
int lastIndex;
int curModCount;
final int lastIndex;
final int curModCount;
boolean hasMoved = false;
private CircularIterator() {
@ -399,9 +399,9 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
private class CircularListIterator<E> implements ListIterator<E> {
int cursor;
int lastIndex;
int firstIndex;
int curModCount;
final int lastIndex;
final int firstIndex;
final int curModCount;
boolean hasMoved = false;
private CircularListIterator() {

View file

@ -32,7 +32,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
import java.io.StreamCorruptedException;
/**
*

View file

@ -42,9 +42,9 @@ import mage.target.Target;
*/
public class TargetAddress {
protected int spellAbilityIndex;
protected UUID mode;
protected int targetIndex;
protected final int spellAbilityIndex;
protected final UUID mode;
protected final int targetIndex;
public TargetAddress(int spellAbilityIndex, UUID mode, int targetIndex) {
this.spellAbilityIndex = spellAbilityIndex;
@ -68,7 +68,7 @@ public class TargetAddress {
protected static class TargetAddressIterator implements Iterator<TargetAddress> {
protected Iterator<SpellAbility> spellAbilityIterator;
protected final Iterator<SpellAbility> spellAbilityIterator;
protected Integer lastSpellAbilityIndex = null;
protected Iterator<UUID> modeIterator = null;
protected Modes modes = null;

View file

@ -6,7 +6,7 @@ package mage.util;
*/
public class ThreadLocalStringBuilder extends ThreadLocal<StringBuilder> {
private int size;
private final int size;
public ThreadLocalStringBuilder(int size) {
this.size = size;

View file

@ -28,7 +28,6 @@
package mage.watchers;
import java.util.HashMap;
import java.util.Iterator;
import java.util.UUID;
import mage.game.Game;
import mage.game.events.GameEvent;
@ -43,7 +42,7 @@ public class Watchers extends HashMap<String, Watcher> {
}
public Watchers(final Watchers watchers) {
watchers.entrySet().stream().forEach((entry) -> this.put(entry.getKey(), entry.getValue().copy()));
watchers.entrySet().forEach((entry) -> this.put(entry.getKey(), entry.getValue().copy()));
}
public Watchers copy() {
@ -63,7 +62,7 @@ public class Watchers extends HashMap<String, Watcher> {
}
public void reset() {
this.values().stream().forEach(Watcher::reset);
this.values().forEach(Watcher::reset);
}
public Watcher get(String key, UUID id) {

View file

@ -66,11 +66,7 @@ public class CastFromGraveyardWatcher extends Watcher {
if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getZone().equals(Zone.GRAVEYARD)) {
Spell spell = (Spell) game.getObject(event.getTargetId());
if (spell != null) {
HashSet<Integer> zcc = spellsCastFromGraveyard.get(spell.getSourceId());
if (zcc == null) {
zcc = new HashSet<>();
spellsCastFromGraveyard.put(spell.getSourceId(), zcc);
}
HashSet<Integer> zcc = spellsCastFromGraveyard.computeIfAbsent(spell.getSourceId(), k -> new HashSet<>());
zcc.add(spell.getZoneChangeCounter(game));
}

View file

@ -64,9 +64,4 @@ public class FirstTimeStepWatcher extends Watcher {
condition = true;
}
}
@Override
public void reset() {
super.reset();
}
}