20 package net.sf.gridarta.model.spells;
22 import java.util.ArrayList;
23 import java.util.Collections;
24 import java.util.Comparator;
25 import java.util.Iterator;
26 import java.util.List;
27 import org.jetbrains.annotations.NotNull;
39 private final List<S>
spells =
new ArrayList<>();
47 public int compare(
final Spell o1,
final Spell o2) {
48 return String.CASE_INSENSITIVE_ORDER.compare(o1.
getName(), o2.
getName());
57 spells.sort(SPELL_COMPARATOR);
75 return Collections.unmodifiableList(spells).iterator();
82 public void add(@NotNull
final S spell) {
93 return spells.get(index);
94 }
catch (
final IndexOutOfBoundsException ignored) {
Iterator< S > iterator()
Return all known spell objects.
Common base class for spells and spell lists.
static final Comparator< Spell > SPELL_COMPARATOR
A comparator to sort spells by name.
void sort()
Sort the added spells after loading is finished.
final List< S > spells
All defined spells.
Describes an in-game spell.
String getName()
Return the spell name.
void add(@NotNull final S spell)
Add a spell.
S getSpell(final int index)
Return one spell object by index.
int size()
Return the number of existing spell objects.