mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Big Cleanup
This commit is contained in:
@@ -175,7 +175,7 @@ public class CardStorageReader {
|
||||
}
|
||||
|
||||
if (zipEntriesMap == null) {
|
||||
zipEntriesMap = new HashMap<String, ZipEntry>();
|
||||
zipEntriesMap = new HashMap<>();
|
||||
for (ZipEntry entry : getZipEntries()) {
|
||||
zipEntriesMap.put(entry.getName(), entry);
|
||||
}
|
||||
@@ -256,7 +256,7 @@ public class CardStorageReader {
|
||||
return result;
|
||||
}
|
||||
|
||||
final List<File> allFiles = collectCardFiles(new ArrayList<File>(), this.cardsfolder);
|
||||
final List<File> allFiles = collectCardFiles(new ArrayList<>(), this.cardsfolder);
|
||||
if (!allFiles.isEmpty()) {
|
||||
int fileParts = zip == null ? NUMBER_OF_PARTS : 1 + NUMBER_OF_PARTS / 3;
|
||||
if (allFiles.size() < fileParts * 100) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.Map;
|
||||
|
||||
public class FTrace {
|
||||
private static long appStartTime;
|
||||
private static Map<String, FTrace> traces = new HashMap<String, FTrace>();
|
||||
private static Map<String, FTrace> traces = new HashMap<>();
|
||||
|
||||
public static void initialize() {
|
||||
appStartTime = new Date().getTime();
|
||||
|
||||
@@ -110,7 +110,7 @@ public class StaticData {
|
||||
private List<CardEdition> sortedEditions;
|
||||
public final List<CardEdition> getSortedEditions() {
|
||||
if (sortedEditions == null) {
|
||||
sortedEditions = new ArrayList<CardEdition>();
|
||||
sortedEditions = new ArrayList<>();
|
||||
for (CardEdition set : editions) {
|
||||
sortedEditions.add(set);
|
||||
}
|
||||
|
||||
@@ -41,16 +41,16 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
public final static char NameSetSeparator = '|';
|
||||
|
||||
// need this to obtain cardReference by name+set+artindex
|
||||
private final ListMultimap<String, PaperCard> allCardsByName = Multimaps.newListMultimap(new TreeMap<String,Collection<PaperCard>>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists());
|
||||
private final ListMultimap<String, PaperCard> allCardsByName = Multimaps.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists());
|
||||
private final Map<String, PaperCard> uniqueCardsByName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
|
||||
private final Map<String, CardRules> rulesByName;
|
||||
private final Map<String, ICardFace> facesByName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
|
||||
private static Map<String, String> artPrefs = new HashMap<String, String>();
|
||||
private static Map<String, String> artPrefs = new HashMap<>();
|
||||
|
||||
private final Map<String, String> alternateName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
|
||||
private final Map<String, Integer> artIds = new HashMap<String, Integer>();
|
||||
private final Map<String, Integer> artIds = new HashMap<>();
|
||||
|
||||
private final List<PaperCard> allCards = new ArrayList<PaperCard>();
|
||||
private final List<PaperCard> allCards = new ArrayList<>();
|
||||
private final List<PaperCard> roAllCards = Collections.unmodifiableList(allCards);
|
||||
private final CardEdition.Collection editions;
|
||||
|
||||
@@ -166,8 +166,8 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
}
|
||||
|
||||
public void initialize(boolean logMissingPerEdition, boolean logMissingSummary) {
|
||||
Set<String> allMissingCards = new LinkedHashSet<String>();
|
||||
List<String> missingCards = new ArrayList<String>();
|
||||
Set<String> allMissingCards = new LinkedHashSet<>();
|
||||
List<String> missingCards = new ArrayList<>();
|
||||
CardEdition upcomingSet = null;
|
||||
Date today = new Date();
|
||||
|
||||
@@ -342,10 +342,10 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
if (request.artIndex <= 0) { // this stands for 'random art'
|
||||
Collection<PaperCard> candidates;
|
||||
if (reqEdition == null) {
|
||||
candidates = new ArrayList<PaperCard>(cards);
|
||||
candidates = new ArrayList<>(cards);
|
||||
}
|
||||
else {
|
||||
candidates = new ArrayList<PaperCard>();
|
||||
candidates = new ArrayList<>();
|
||||
for (PaperCard pc : cards) {
|
||||
if (pc.getEdition().equalsIgnoreCase(reqEdition)) {
|
||||
candidates.add(pc);
|
||||
@@ -452,7 +452,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
firstWithoutImage = pc; //ensure first without image returns if none have image
|
||||
}
|
||||
if (cardsListReadOnly) { //ensure we don't modify a cached collection
|
||||
cards = new ArrayList<PaperCard>(cards);
|
||||
cards = new ArrayList<>(cards);
|
||||
cardsListReadOnly = false;
|
||||
}
|
||||
cards.remove(randomIndex); //remove card from collection and try another random card
|
||||
@@ -686,7 +686,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
result = rulesByName.put(cardName, rules);
|
||||
|
||||
// 1. generate all paper cards from edition data we have (either explicit, or found in res/editions, or add to unknown edition)
|
||||
List<PaperCard> paperCards = new ArrayList<PaperCard>();
|
||||
List<PaperCard> paperCards = new ArrayList<>();
|
||||
if (null == whenItWasPrinted || whenItWasPrinted.isEmpty()) {
|
||||
for (CardEdition e : editions.getOrderedEditions()) {
|
||||
int artIdx = 1;
|
||||
|
||||
@@ -24,8 +24,8 @@ final class CardFace implements ICardFace {
|
||||
}
|
||||
|
||||
|
||||
private final static List<String> emptyList = Collections.unmodifiableList(new ArrayList<String>());
|
||||
private final static Map<String, String> emptyMap = Collections.unmodifiableMap(new TreeMap<String, String>());
|
||||
private final static List<String> emptyList = Collections.unmodifiableList(new ArrayList<>());
|
||||
private final static Map<String, String> emptyMap = Collections.unmodifiableMap(new TreeMap<>());
|
||||
|
||||
private final String name;
|
||||
private String altName = null;
|
||||
@@ -112,12 +112,12 @@ final class CardFace implements ICardFace {
|
||||
|
||||
// Raw fields used for Card creation
|
||||
void setNonAbilityText(String value) { this.nonAbilityText = value; }
|
||||
void addKeyword(String value) { if (null == this.keywords) { this.keywords = new ArrayList<String>(); } this.keywords.add(value); }
|
||||
void addAbility(String value) { if (null == this.abilities) { this.abilities = new ArrayList<String>(); } this.abilities.add(value);}
|
||||
void addTrigger(String value) { if (null == this.triggers) { this.triggers = new ArrayList<String>(); } this.triggers.add(value);}
|
||||
void addStaticAbility(String value) { if (null == this.staticAbilities) { this.staticAbilities = new ArrayList<String>(); } this.staticAbilities.add(value);}
|
||||
void addReplacementEffect(String value) { if (null == this.replacements) { this.replacements = new ArrayList<String>(); } this.replacements.add(value);}
|
||||
void addSVar(String key, String value) { if (null == this.variables) { this.variables = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); } this.variables.put(key, value); }
|
||||
void addKeyword(String value) { if (null == this.keywords) { this.keywords = new ArrayList<>(); } this.keywords.add(value); }
|
||||
void addAbility(String value) { if (null == this.abilities) { this.abilities = new ArrayList<>(); } this.abilities.add(value);}
|
||||
void addTrigger(String value) { if (null == this.triggers) { this.triggers = new ArrayList<>(); } this.triggers.add(value);}
|
||||
void addStaticAbility(String value) { if (null == this.staticAbilities) { this.staticAbilities = new ArrayList<>(); } this.staticAbilities.add(value);}
|
||||
void addReplacementEffect(String value) { if (null == this.replacements) { this.replacements = new ArrayList<>(); } this.replacements.add(value);}
|
||||
void addSVar(String key, String value) { if (null == this.variables) { this.variables = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); } this.variables.put(key, value); }
|
||||
|
||||
|
||||
void assignMissingFields() { // Most scripts do not specify color explicitly
|
||||
|
||||
@@ -627,7 +627,7 @@ public final class CardRulesPredicates {
|
||||
public static final Predicate<CardRules> IS_MONOCOLOR = CardRulesPredicates.hasCntColors((byte) 1);
|
||||
|
||||
/** The Constant colors. */
|
||||
public static final List<Predicate<CardRules>> COLORS = new ArrayList<Predicate<CardRules>>();
|
||||
public static final List<Predicate<CardRules>> COLORS = new ArrayList<>();
|
||||
static {
|
||||
Presets.COLORS.add(Presets.IS_WHITE);
|
||||
Presets.COLORS.add(Presets.IS_BLUE);
|
||||
|
||||
@@ -320,7 +320,7 @@ public final class ColorSet implements Comparable<ColorSet>, Iterable<Byte>, Ser
|
||||
if (isColorless()) {
|
||||
return EnumSet.of(Color.COLORLESS);
|
||||
}
|
||||
List<Color> list = new ArrayList<Color>();
|
||||
List<Color> list = new ArrayList<>();
|
||||
for (Color c : Color.values()) {
|
||||
if (hasAnyColor(c.getColormask())) {
|
||||
list.add(c);
|
||||
|
||||
@@ -96,7 +96,7 @@ public class PrintSheet {
|
||||
number -= uniqueCards;
|
||||
}
|
||||
|
||||
List<PaperCard> uniques = wantUnique ? new ArrayList<PaperCard>() : null;
|
||||
List<PaperCard> uniques = wantUnique ? new ArrayList<>() : null;
|
||||
for(int iC = 0; iC < number; iC++) {
|
||||
int index = MyRandom.getRandom().nextInt(totalWeight);
|
||||
PaperCard toAdd = fetchRoulette(0, index, wantUnique ? uniques : null);
|
||||
|
||||
@@ -39,8 +39,8 @@ import java.util.Map.Entry;
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPool>> {
|
||||
private final Map<DeckSection, CardPool> parts = new EnumMap<DeckSection, CardPool>(DeckSection.class);
|
||||
private final Set<String> tags = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
|
||||
private final Map<DeckSection, CardPool> parts = new EnumMap<>(DeckSection.class);
|
||||
private final Set<String> tags = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
|
||||
// Supports deferring loading a deck until we actually need its contents. This works in conjunction with
|
||||
// the lazy card load feature to ensure we don't need to load all cards on start up.
|
||||
private Map<String, List<String>> deferredSections;
|
||||
|
||||
@@ -263,7 +263,7 @@ public enum DeckFormat {
|
||||
}
|
||||
}
|
||||
|
||||
final List<PaperCard> erroneousCI = new ArrayList<PaperCard>();
|
||||
final List<PaperCard> erroneousCI = new ArrayList<>();
|
||||
|
||||
Set<String> basicLandNames = new HashSet<>();
|
||||
for (final Entry<PaperCard, Integer> cp : deck.get(DeckSection.Main)) {
|
||||
@@ -306,7 +306,7 @@ public enum DeckFormat {
|
||||
}
|
||||
|
||||
if (cardPoolFilter != null) {
|
||||
final List<PaperCard> erroneousCI = new ArrayList<PaperCard>();
|
||||
final List<PaperCard> erroneousCI = new ArrayList<>();
|
||||
for (final Entry<PaperCard, Integer> cp : deck.getAllCardsInASinglePool()) {
|
||||
if (!cardPoolFilter.apply(cp.getKey().getRules())) {
|
||||
erroneousCI.add(cp.getKey());
|
||||
|
||||
@@ -37,7 +37,7 @@ public class DeckGroup extends DeckBase {
|
||||
|
||||
private static final long serialVersionUID = -1628725522049635829L;
|
||||
private Deck humanDeck;
|
||||
private List<Deck> aiDecks = new ArrayList<Deck>();
|
||||
private List<Deck> aiDecks = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Gets the human deck.
|
||||
|
||||
@@ -11,7 +11,7 @@ import forge.item.IPaperCard;
|
||||
import forge.item.PaperCard;
|
||||
|
||||
public class DeckGenPool implements IDeckGenPool {
|
||||
private final Map<String, PaperCard> cards = new HashMap<String, PaperCard>();
|
||||
private final Map<String, PaperCard> cards = new HashMap<>();
|
||||
|
||||
public DeckGenPool() {
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public abstract class DeckGeneratorBase {
|
||||
protected final DebugTrace trace = new DebugTrace();
|
||||
protected final Map<String, Integer> cardCounts = new HashMap<String, Integer>();
|
||||
protected final Map<String, Integer> cardCounts = new HashMap<>();
|
||||
protected int maxDuplicates = 4;
|
||||
protected boolean useArtifacts = true;
|
||||
protected String basicLandEdition = null;
|
||||
@@ -299,7 +299,7 @@ public abstract class DeckGeneratorBase {
|
||||
protected static Map<String, Integer> countLands(ItemPool<PaperCard> outList) {
|
||||
// attempt to optimize basic land counts according
|
||||
// to color representation
|
||||
Map<String, Integer> res = new TreeMap<String, Integer>();
|
||||
Map<String, Integer> res = new TreeMap<>();
|
||||
// count each card color using mana costs
|
||||
// TODO: count hybrid mana differently?
|
||||
for (Entry<PaperCard, Integer> cpe : outList) {
|
||||
@@ -418,7 +418,7 @@ public abstract class DeckGeneratorBase {
|
||||
}
|
||||
|
||||
public List<String> regexLandSearch(String pattern, Iterable<PaperCard> landCards){
|
||||
final List<String> dLands = new ArrayList<String>();
|
||||
final List<String> dLands = new ArrayList<>();
|
||||
Pattern p = Pattern.compile(pattern);
|
||||
for (PaperCard card:landCards){
|
||||
if (card.getRules().getAiHints().getRemAIDecks()) {
|
||||
|
||||
@@ -74,7 +74,7 @@ public class DeckFileHeader {
|
||||
this.deckType = DeckFormat.smartValueOf(kvPairs.get(DeckFileHeader.DECK_TYPE), DeckFormat.Constructed);
|
||||
this.customPool = kvPairs.getBoolean(DeckFileHeader.CSTM_POOL);
|
||||
this.intendedForAi = "computer".equalsIgnoreCase(kvPairs.get(DeckFileHeader.PLAYER)) || "ai".equalsIgnoreCase(kvPairs.get(DeckFileHeader.PLAYER_TYPE));
|
||||
this.tags = new TreeSet<String>();
|
||||
this.tags = new TreeSet<>();
|
||||
|
||||
String rawTags = kvPairs.get(DeckFileHeader.TAGS);
|
||||
if( StringUtils.isNotBlank(rawTags) ) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class DeckSerializer {
|
||||
}
|
||||
|
||||
private static List<String> serializeDeck(Deck d) {
|
||||
final List<String> out = new ArrayList<String>();
|
||||
final List<String> out = new ArrayList<>();
|
||||
out.add(TextUtil.enclosedBracket("metadata"));
|
||||
|
||||
out.add(TextUtil.concatNoSpace(DeckFileHeader.NAME,"=", d.getName().replaceAll("\n", "")));
|
||||
|
||||
@@ -93,7 +93,7 @@ public class BoosterBox extends BoxedProduct {
|
||||
final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ',');
|
||||
int nBoosters = 6;
|
||||
|
||||
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>();
|
||||
List<Pair<String, Integer>> slots = new ArrayList<>();
|
||||
for(String slotDesc : data) {
|
||||
String[] kv = TextUtil.split(slotDesc, ' ', 2);
|
||||
if (kv[1].startsWith("Booster"))
|
||||
|
||||
@@ -44,7 +44,7 @@ public abstract class BoxedProduct extends SealedProduct {
|
||||
}
|
||||
|
||||
public List<PaperCard> getExtraCards() {
|
||||
return new ArrayList<PaperCard>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -111,7 +111,7 @@ public class FatPack extends BoxedProduct {
|
||||
final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ',');
|
||||
int nBoosters = 6;
|
||||
|
||||
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>();
|
||||
List<Pair<String, Integer>> slots = new ArrayList<>();
|
||||
for(String slotDesc : data) {
|
||||
String[] kv = TextUtil.split(slotDesc, ' ', 2);
|
||||
if (kv[1].startsWith("Booster"))
|
||||
|
||||
@@ -124,7 +124,7 @@ public class Aggregates {
|
||||
}
|
||||
|
||||
public static final <T> List<T> random(final Iterable<T> source, final int count) {
|
||||
return random(source, count, new ArrayList<T>());
|
||||
return random(source, count, new ArrayList<>());
|
||||
}
|
||||
public static final <T, L extends List<T>> L random(final Iterable<T> source, final int count, final L list) {
|
||||
// Using Reservoir Sampling to grab X random values from source
|
||||
@@ -163,7 +163,7 @@ public class Aggregates {
|
||||
}
|
||||
|
||||
public static final <K, U> Iterable<U> uniqueByLast(final Iterable<U> source, final Function<U, K> fnUniqueKey) { // this might be exotic
|
||||
final Map<K, U> uniques = new Hashtable<K, U>();
|
||||
final Map<K, U> uniques = new Hashtable<>();
|
||||
for (final U c : source) {
|
||||
uniques.put(fnUniqueKey.apply(c), c);
|
||||
}
|
||||
@@ -206,7 +206,7 @@ public class Aggregates {
|
||||
}
|
||||
|
||||
public static <T, U> Iterable<Entry<U, Integer>> groupSumBy(Iterable<Entry<T, Integer>> source, Function<T, U> fnGetField) {
|
||||
Map<U, Integer> result = new HashMap<U, Integer>();
|
||||
Map<U, Integer> result = new HashMap<>();
|
||||
for (Entry<T, Integer> kv : source) {
|
||||
U k = fnGetField.apply(kv.getKey());
|
||||
Integer v = kv.getValue();
|
||||
|
||||
@@ -50,7 +50,7 @@ public class FileSection {
|
||||
* Instantiates a new file section.
|
||||
*/
|
||||
protected FileSection() {
|
||||
this(new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER));
|
||||
this(new TreeMap<>(String.CASE_INSENSITIVE_ORDER));
|
||||
}
|
||||
|
||||
protected FileSection(Map<String, String> lines0) {
|
||||
@@ -71,7 +71,7 @@ public class FileSection {
|
||||
}
|
||||
|
||||
public static Map<String, String> parseToMap(final String line, final String kvSeparator, final String pairSeparator) {
|
||||
Map<String, String> result = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
|
||||
Map<String, String> result = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
if (!StringUtils.isEmpty(line)) {
|
||||
final String[] pairs = line.split(Pattern.quote(pairSeparator));
|
||||
final Pattern splitter = Pattern.compile(Pattern.quote(kvSeparator));
|
||||
@@ -211,7 +211,7 @@ public class FileSection {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map<String, List<String>> parseSections(final List<String> source) {
|
||||
final Map<String, List<String>> result = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
|
||||
final Map<String, List<String>> result = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
String currentSection = "";
|
||||
List<String> currentList = null;
|
||||
|
||||
@@ -234,7 +234,7 @@ public class FileSection {
|
||||
currentList = null;
|
||||
} else {
|
||||
if (currentList == null) {
|
||||
currentList = new ArrayList<String>();
|
||||
currentList = new ArrayList<>();
|
||||
}
|
||||
currentList.add(st);
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public final class FileUtil {
|
||||
public static List<String> readFile(final File file) {
|
||||
try {
|
||||
if ((file == null) || !file.exists()) {
|
||||
return new ArrayList<String>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return FileUtil.readAllLines(new FileReader(file), false);
|
||||
} catch (final Exception ex) {
|
||||
@@ -222,7 +222,7 @@ public final class FileUtil {
|
||||
* @return list of strings
|
||||
*/
|
||||
public static List<String> readAllLines(final Reader reader, final boolean mayTrim) {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
try {
|
||||
final BufferedReader in = new BufferedReader(reader);
|
||||
String line;
|
||||
@@ -244,7 +244,7 @@ public final class FileUtil {
|
||||
Pattern lineSplitter = Pattern.compile(Pattern.quote(" "));
|
||||
Pattern replacer = Pattern.compile(Pattern.quote("%20"));
|
||||
|
||||
List<Pair<String, String>> list = new ArrayList<Pair<String, String>>();
|
||||
List<Pair<String, String>> list = new ArrayList<>();
|
||||
|
||||
for (String line : readFile(nameUrlFile)) {
|
||||
if (StringUtils.isBlank(line) || line.startsWith("#")) {
|
||||
@@ -271,7 +271,7 @@ public final class FileUtil {
|
||||
}
|
||||
|
||||
public static List<String> readFile(final URL url) {
|
||||
final List<String> lines = new ArrayList<String>();
|
||||
final List<String> lines = new ArrayList<>();
|
||||
ThreadUtil.executeWithTimeout(new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
|
||||
@@ -60,12 +60,12 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
|
||||
};
|
||||
|
||||
public ItemPool(final Class<T> cls) {
|
||||
this(new LinkedHashMap<T, Integer>(), cls);
|
||||
this(new LinkedHashMap<>(), cls);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <Tin extends InventoryItem, Tout extends InventoryItem> ItemPool<Tout> createFrom(final ItemPool<Tin> from, final Class<Tout> clsHint) {
|
||||
final ItemPool<Tout> result = new ItemPool<Tout>(clsHint);
|
||||
final ItemPool<Tout> result = new ItemPool<>(clsHint);
|
||||
if (from != null) {
|
||||
for (final Entry<Tin, Integer> e : from) {
|
||||
final Tin srcKey = e.getKey();
|
||||
@@ -79,7 +79,7 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <Tin extends InventoryItem, Tout extends InventoryItem> ItemPool<Tout> createFrom(final Iterable<Tin> from, final Class<Tout> clsHint) {
|
||||
final ItemPool<Tout> result = new ItemPool<Tout>(clsHint);
|
||||
final ItemPool<Tout> result = new ItemPool<>(clsHint);
|
||||
if (from != null) {
|
||||
for (final Tin srcKey : from) {
|
||||
if (clsHint.isInstance(srcKey)) {
|
||||
@@ -95,7 +95,7 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
|
||||
items = items0;
|
||||
}
|
||||
else {
|
||||
items = new HashMap<T, Integer>(); //prevent items being null
|
||||
items = new HashMap<>(); //prevent items being null
|
||||
}
|
||||
myClass = cls;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
|
||||
}
|
||||
|
||||
public final List<T> toFlatList() {
|
||||
final List<T> result = new ArrayList<T>();
|
||||
final List<T> result = new ArrayList<>();
|
||||
for (final Entry<T, Integer> e : this) {
|
||||
for (int i = 0; i < e.getValue(); i++) {
|
||||
result.add(e.getKey());
|
||||
@@ -171,7 +171,7 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
|
||||
}
|
||||
|
||||
public Map<String, Integer> toNameLookup() {
|
||||
final Map<String, Integer> result = new HashMap<String, Integer>();
|
||||
final Map<String, Integer> result = new HashMap<>();
|
||||
for (final Entry<T, Integer> e : this) {
|
||||
result.put(e.getKey().getName(), e.getValue());
|
||||
}
|
||||
@@ -183,7 +183,7 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
|
||||
}
|
||||
|
||||
public ItemPool<T> getView() {
|
||||
return new ItemPool<T>(Collections.unmodifiableMap(items), getMyClass());
|
||||
return new ItemPool<>(Collections.unmodifiableMap(items), getMyClass());
|
||||
}
|
||||
|
||||
public void add(final T item) {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ItemPoolSorter<T> implements Comparator<Entry<T, Integer>> {
|
||||
}
|
||||
|
||||
/** The Constant byNameThenSet. */
|
||||
public static final ItemPoolSorter<PaperCard> BY_NAME_THEN_SET = new ItemPoolSorter<PaperCard>(
|
||||
public static final ItemPoolSorter<PaperCard> BY_NAME_THEN_SET = new ItemPoolSorter<>(
|
||||
new Function<Entry<PaperCard, Integer>, Comparable<?>>() {
|
||||
@Override
|
||||
public Comparable<?> apply(final Entry<PaperCard, Integer> from) {
|
||||
|
||||
@@ -195,7 +195,7 @@ public final class NameGenerator {
|
||||
"Coreshaker", "Forgewulf", "Sheepspear", "Elvenworm", "Lipswalker", "Sealight", "the Rotten"
|
||||
};
|
||||
|
||||
private static List<String> usedMonikers = new ArrayList<String>();
|
||||
private static List<String> usedMonikers = new ArrayList<>();
|
||||
private static List<String> usedNames;
|
||||
private static String[] sourceList;
|
||||
|
||||
@@ -239,8 +239,8 @@ public final class NameGenerator {
|
||||
break;
|
||||
|
||||
default:
|
||||
List<String> all = new ArrayList<String>(
|
||||
genericMales.length + fantasyMales.length + genericFemales.length + fantasyFemales.length);
|
||||
List<String> all = new ArrayList<>(
|
||||
genericMales.length + fantasyMales.length + genericFemales.length + fantasyFemales.length);
|
||||
Collections.addAll(all, genericMales);
|
||||
Collections.addAll(all, fantasyMales);
|
||||
Collections.addAll(all, genericFemales);
|
||||
@@ -272,7 +272,7 @@ public final class NameGenerator {
|
||||
/** Generates a specified number of random names. */
|
||||
public static List<String> getRandomNames(final int generateAmount, final List<String> excludeNames) {
|
||||
usedNames = excludeNames;
|
||||
final List<String> names = new ArrayList<String>(generateAmount);
|
||||
final List<String> names = new ArrayList<>(generateAmount);
|
||||
for (int i = 0; i < generateAmount; i++) {
|
||||
getRandomName("Any", "Any", usedNames);
|
||||
}
|
||||
@@ -281,7 +281,7 @@ public final class NameGenerator {
|
||||
|
||||
/** Generates a single name that doesn't match any names in the supplied list. */
|
||||
public static String getRandomName(final String gender, final String type, final String notNamed) {
|
||||
List<String> exclude = new ArrayList<String>(1);
|
||||
List<String> exclude = new ArrayList<>(1);
|
||||
exclude.add(notNamed);
|
||||
return getRandomName(gender, type, exclude);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class TextUtil {
|
||||
* It's faster than String.split, and allows parenthesis
|
||||
*/
|
||||
public static String[] splitWithParenthesis(CharSequence input, char delimiter, int maxEntries, char openPar, char closePar, boolean skipEmpty) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
List<String> result = new ArrayList<>();
|
||||
// Assume that when equal non-zero parenthesis are passed, they need to be discarded
|
||||
boolean trimParenthesis = openPar == closePar && openPar > 0;
|
||||
int nPar = 0;
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.Set;
|
||||
public class FCollection<T> implements List<T>, /*Set<T>,*/ FCollectionView<T>, Cloneable, Serializable {
|
||||
private static final long serialVersionUID = -1664555336364294106L;
|
||||
|
||||
private static final FCollection<?> EMPTY = new EmptyFCollection<Object>();
|
||||
private static final FCollection<?> EMPTY = new EmptyFCollection<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> FCollection<T> getEmpty() {
|
||||
@@ -527,7 +527,7 @@ public class FCollection<T> implements List<T>, /*Set<T>,*/ FCollectionView<T>,
|
||||
@Override
|
||||
public Iterable<T> threadSafeIterable() {
|
||||
//create a new linked list for iterating to make it thread safe and avoid concurrent modification exceptions
|
||||
return Iterables.unmodifiableIterable(new LinkedList<T>(list));
|
||||
return Iterables.unmodifiableIterable(new LinkedList<>(list));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,7 +6,7 @@ public class LinkedHashMapToAmount<T> extends LinkedHashMap<T, Integer> implemen
|
||||
private static final long serialVersionUID = 1438913784333297606L;
|
||||
|
||||
public static <T> LinkedHashMapToAmount<T> emptyMap() {
|
||||
return new LinkedHashMapToAmount<T>(0);
|
||||
return new LinkedHashMapToAmount<>(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,11 +59,11 @@ public final class MapToAmountUtil {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (map.isEmpty()) {
|
||||
return new FCollection<T>();
|
||||
return new FCollection<>();
|
||||
}
|
||||
|
||||
final int max = Collections.max(map.values());
|
||||
final FCollection<T> set = new FCollection<T>();
|
||||
final FCollection<T> set = new FCollection<>();
|
||||
for (final Entry<T, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue().intValue() == max) {
|
||||
set.add(entry.getKey());
|
||||
@@ -114,11 +114,11 @@ public final class MapToAmountUtil {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (map.isEmpty()) {
|
||||
return new FCollection<T>();
|
||||
return new FCollection<>();
|
||||
}
|
||||
|
||||
final int min = Collections.min(map.values());
|
||||
final FCollection<T> set = new FCollection<T>();
|
||||
final FCollection<T> set = new FCollection<>();
|
||||
for (final Entry<T, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue().intValue() == min) {
|
||||
set.add(entry.getKey());
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.util.*;
|
||||
public class StorageBase<T> implements IStorage<T> {
|
||||
protected final Map<String, T> map;
|
||||
|
||||
public final static StorageBase<?> emptyMap = new StorageBase<Object>("Empty", null, new HashMap<String, Object>());
|
||||
public final static StorageBase<?> emptyMap = new StorageBase<>("Empty", null, new HashMap<>());
|
||||
public final String name, fullPath;
|
||||
|
||||
public StorageBase(final String name0, final IItemReader<T> io) {
|
||||
@@ -55,7 +55,7 @@ public class StorageBase<T> implements IStorage<T> {
|
||||
|
||||
@Override
|
||||
public final Collection<String> getItemNames() {
|
||||
return new ArrayList<String>(map.keySet());
|
||||
return new ArrayList<>(map.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,7 +39,7 @@ public class StorageImmediatelySerialized<T> extends StorageBase<T> {
|
||||
private final Function<File, IStorage<T>> nestedFactory = new Function<File, IStorage<T>>() {
|
||||
@Override
|
||||
public IStorage<T> apply(File file) {
|
||||
return new StorageImmediatelySerialized<T>(file.getName(), (IItemSerializer<T>) serializer.getReaderForFolder(file), true);
|
||||
return new StorageImmediatelySerialized<>(file.getName(), (IItemSerializer<T>) serializer.getReaderForFolder(file), true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,7 +57,7 @@ public class StorageImmediatelySerialized<T> extends StorageBase<T> {
|
||||
public StorageImmediatelySerialized(String name, final IItemSerializer<T> io, boolean withSubFolders) {
|
||||
super(name, io);
|
||||
this.serializer = io;
|
||||
subfolders = withSubFolders ? new StorageNestedFolders<T>(io.getDirectory(), io.getSubFolders(), nestedFactory) : null;
|
||||
subfolders = withSubFolders ? new StorageNestedFolders<>(io.getDirectory(), io.getSubFolders(), nestedFactory) : null;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -9,7 +9,7 @@ public class StorageNestedFolders<T> extends StorageBase<IStorage<T>> {
|
||||
private final File thisFolder;
|
||||
|
||||
public StorageNestedFolders(File thisFolder, Iterable<File> subfolders, Function<File, IStorage<T>> factory) {
|
||||
super("<Subfolders>", thisFolder.getPath(), new HashMap<String, IStorage<T>>());
|
||||
super("<Subfolders>", thisFolder.getPath(), new HashMap<>());
|
||||
this.thisFolder = thisFolder;
|
||||
for (File sf : subfolders) {
|
||||
IStorage<T> newUnit = factory.apply(sf);
|
||||
|
||||
@@ -52,7 +52,7 @@ public abstract class StorageReaderFile<T> extends StorageReaderBase<T> {
|
||||
|
||||
@Override
|
||||
public Map<String, T> readAll() {
|
||||
final Map<String, T> result = new TreeMap<String, T>();
|
||||
final Map<String, T> result = new TreeMap<>();
|
||||
|
||||
int idx = 0;
|
||||
for (String line : FileUtil.readFile(file)) {
|
||||
|
||||
@@ -53,7 +53,7 @@ public abstract class StorageReaderFileSections<T> extends StorageReaderBase<T>
|
||||
}
|
||||
|
||||
protected Map<String, T> createMap() {
|
||||
return new TreeMap<String, T>();
|
||||
return new TreeMap<>();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -66,7 +66,7 @@ public abstract class StorageReaderFileSections<T> extends StorageReaderBase<T>
|
||||
int idx = 0;
|
||||
Iterable<String> contents = FileUtil.readFile(file);
|
||||
|
||||
List<String> accumulator = new ArrayList<String>();
|
||||
List<String> accumulator = new ArrayList<>();
|
||||
String header = null;
|
||||
|
||||
for (final String s : contents) {
|
||||
|
||||
@@ -75,14 +75,14 @@ public abstract class StorageReaderFolder<T> extends StorageReaderBase<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public final List<String> objectsThatFailedToLoad = new ArrayList<String>();
|
||||
public final List<String> objectsThatFailedToLoad = new ArrayList<>();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.util.IItemReader#readAll()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, T> readAll() {
|
||||
final Map<String, T> result = new TreeMap<String, T>();
|
||||
final Map<String, T> result = new TreeMap<>();
|
||||
|
||||
final File[] files = this.directory.listFiles(this.getFileFilter());
|
||||
for (final File file : files) {
|
||||
|
||||
@@ -77,14 +77,14 @@ public abstract class StorageReaderRecursiveFolderWithUserFolder<T> extends Stor
|
||||
}
|
||||
}
|
||||
|
||||
public final List<String> objectsThatFailedToLoad = new ArrayList<String>();
|
||||
public final List<String> objectsThatFailedToLoad = new ArrayList<>();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.util.IItemReader#readAll()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, T> readAll() {
|
||||
final Map<String, T> result = new TreeMap<String, T>();
|
||||
final Map<String, T> result = new TreeMap<>();
|
||||
|
||||
Collection<File> forgeFormats = listFileTree(directory);
|
||||
Collection<File> customFormats = listFileTree(userDirectory);
|
||||
@@ -115,7 +115,7 @@ public abstract class StorageReaderRecursiveFolderWithUserFolder<T> extends Stor
|
||||
}
|
||||
|
||||
private Collection<File> listFileTree(File dir) {
|
||||
Set<File> fileTree = new HashSet<File>();
|
||||
Set<File> fileTree = new HashSet<>();
|
||||
if(dir==null||dir.listFiles(getFileFilter())==null){
|
||||
return fileTree;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user