Android Open Source - dnd5spellbook Spell






From Project

Back to project page dnd5spellbook.

License

The source code is released under:

MIT License

If you think the Android project dnd5spellbook listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.dnd5spellbook.domain;
/*www .  ja v a2s . c  o  m*/
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * POJO that describes a single spell
 */
public class Spell {
    private String name;
    private boolean favorite;
    private List<ClassLevelConstraint> classLevelConstraints;

    private static class NameComparator implements Comparator<Spell> {
        @Override
        public int compare(Spell lhs, Spell rhs) {
            return lhs.getName().compareTo(rhs.getName());
        }
    }

    public static Comparator<Spell> NAME_COMPARATOR = new NameComparator();

    /**
     * Creates a new spell with the given name
     *
     * @param name                  name of the spell
     * @param classLevelConstraints class level constraints for this spell
     */
    public Spell(String name, Collection<ClassLevelConstraint> classLevelConstraints) {
        this.name = name;
        this.classLevelConstraints = Collections.unmodifiableList(new ArrayList<>(classLevelConstraints));
    }

    /**
     * @return unmodifiable list of class level constraints for this spell
     */
    public List<ClassLevelConstraint> getClassLevelConstraints() {
        return classLevelConstraints;
    }

    /**
     * @return the name of the spell
     */
    public String getName() {
        return name;
    }

    /**
     * @return true if this spell is favorite by a user and false otherwise
     */
    public boolean isFavorite() {
        return favorite;
    }

    /**
     * Sets whether the spell is a favorite spell
     *
     * @param favorite whether the spell should be marked as favorite or not
     */
    public void setFavorite(boolean favorite) {
        this.favorite = favorite;
    }

    @Override
    public String toString() {
        return "Spell{" +
                "name='" + name + '\'' +
                ", favorite=" + favorite +
                ", classLevelConstraints=" + classLevelConstraints +
                '}';
    }
}




Java Source Code List

org.dnd5spellbook.ApplicationTest.java
org.dnd5spellbook.Constants.java
org.dnd5spellbook.SpellActivity.java
org.dnd5spellbook.SpellAdapter.java
org.dnd5spellbook.SpellBackgroundFactory.java
org.dnd5spellbook.SpellListActivity.java
org.dnd5spellbook.SpellLoaderTest.java
org.dnd5spellbook.SpellLoader.java
org.dnd5spellbook.SwipeListViewTouchListener.java
org.dnd5spellbook.domain.ClassLevelConstraint.java
org.dnd5spellbook.domain.ClassName.java
org.dnd5spellbook.domain.Spell.java