Search in sources :

Example 1 with Category

use of pcgen.cdom.base.Category in project pcgen by PCGen.

the class AbstractReferenceContext method forget.

public <T extends Loadable> boolean forget(T obj) {
    if (CATEGORIZED_CLASS.isAssignableFrom(obj.getClass())) {
        Class cl = obj.getClass();
        Categorized cdo = (Categorized) obj;
        if (hasManufacturer(cl, cdo.getCDOMCategory())) {
            // Work around a bug in the Eclipse 3.7.0/1 compiler by explicitly extracting a Category<?>
            return getManufacturer(cl, (Category<?>) cdo.getCDOMCategory()).forgetObject(obj);
        }
    } else {
        if (hasManufacturer(obj.getClass())) {
            return getManufacturer((Class<T>) obj.getClass()).forgetObject(obj);
        }
    }
    return false;
}
Also used : Categorized(pcgen.cdom.base.Categorized) Category(pcgen.cdom.base.Category) SubClassCategory(pcgen.cdom.enumeration.SubClassCategory) PCClass(pcgen.core.PCClass) SubClass(pcgen.core.SubClass)

Example 2 with Category

use of pcgen.cdom.base.Category in project pcgen by PCGen.

the class CategorizedAbilityFacet method copyContents.

/**
	 * Copies the contents of the CategorizedAbilityFacet from one Player
	 * Character to another Player Character, based on the given CharIDs
	 * representing those Player Characters.
	 * 
	 * This is a method in CategorizedAbilityFacet in order to avoid exposing
	 * the mutable Map object to other classes. This should not be inlined, as
	 * the Map is internal information to CategorizedAbilityFacet and should not
	 * be exposed to other classes.
	 * 
	 * Note also the copy is a one-time event and no references are maintained
	 * between the Player Characters represented by the given CharIDs (meaning
	 * once this copy takes place, any change to the CategorizedAbilityFacet of
	 * one Player Character will only impact the Player Character where the
	 * CategorizedAbilityFacet was changed).
	 * 
	 * @param source
	 *            The CharID representing the Player Character from which the
	 *            information should be copied
	 * @param copy
	 *            The CharID representing the Player Character to which the
	 *            information should be copied
	 */
@Override
public void copyContents(CharID source, CharID copy) {
    Map<Category<Ability>, Map<Nature, Set<Ability>>> map = getCachedMap(source);
    if (map != null) {
        for (Entry<Category<Ability>, Map<Nature, Set<Ability>>> me : map.entrySet()) {
            Category<Ability> cat = me.getKey();
            for (Entry<Nature, Set<Ability>> nme : me.getValue().entrySet()) {
                Nature nat = nme.getKey();
                ensureCachedSet(copy, cat, nat);
                getCachedSet(copy, cat, nat).addAll(nme.getValue());
            }
        }
    }
}
Also used : Ability(pcgen.core.Ability) Nature(pcgen.cdom.enumeration.Nature) Category(pcgen.cdom.base.Category) Set(java.util.Set) WrappedMapSet(pcgen.base.util.WrappedMapSet) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Category (pcgen.cdom.base.Category)2 HashMap (java.util.HashMap)1 IdentityHashMap (java.util.IdentityHashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 WrappedMapSet (pcgen.base.util.WrappedMapSet)1 Categorized (pcgen.cdom.base.Categorized)1 Nature (pcgen.cdom.enumeration.Nature)1 SubClassCategory (pcgen.cdom.enumeration.SubClassCategory)1 Ability (pcgen.core.Ability)1 PCClass (pcgen.core.PCClass)1 SubClass (pcgen.core.SubClass)1