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;
}
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());
}
}
}
}
Aggregations