Search in sources :

Example 66 with CDOMObject

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

the class ConsolidatedListCommitStrategy method getChangesInMasterList.

@Override
public <T extends CDOMObject> AssociatedChanges<T> getChangesInMasterList(String tokenName, CDOMObject owner, CDOMReference<? extends CDOMList<T>> swl) {
    Set<CDOMObject> added = masterList.getSecondaryKeySet(swl);
    MapToList<T, AssociatedPrereqObject> owned = new TreeMapToList<>(CDOMObjectUtilities.CDOM_SORTER);
    for (CDOMObject lw : added) {
        List<AssociatedPrereqObject> list = masterList.getListFor(swl, lw);
        for (AssociatedPrereqObject assoc : list) {
            if (owner.equals(assoc.getAssociation(AssociationKey.OWNER))) {
                owned.addToListFor((T) lw, assoc);
                break;
            }
        }
    }
    return new AssociatedCollectionChanges<>(owned, null, false);
}
Also used : TreeMapToList(pcgen.base.util.TreeMapToList) CDOMObject(pcgen.cdom.base.CDOMObject) AssociatedPrereqObject(pcgen.cdom.base.AssociatedPrereqObject)

Example 67 with CDOMObject

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

the class EditorReferenceContext method performMod.

@Override
public <T extends CDOMObject> T performMod(T object) {
    try {
        CDOMObject copy = object.getClass().newInstance();
        modMap.addToListFor(object, copy);
    } catch (InstantiationException e) {
        throw new IllegalArgumentException("Class " + object.getClass().getName() + " must possess a zero-argument constructor", e);
    } catch (IllegalAccessException e) {
        throw new IllegalArgumentException("Class " + object.getClass().getName() + " must possess a public zero-argument constructor", e);
    }
    return null;
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject)

Example 68 with CDOMObject

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

the class AbstractListContext method commit.

void commit() {
    ListCommitStrategy commit = getCommitStrategy();
    for (CDOMReference<? extends CDOMList<?>> list : edits.positiveMasterMap.getKeySet()) {
        //Note: Intentional Generics Violation due to Sun Compiler
        commitDirect((CDOMReference) list);
    }
    for (CDOMReference<? extends CDOMList<?>> list : edits.negativeMasterMap.getKeySet()) {
        //Note: Intentional Generics Violation due to Sun Compiler
        removeDirect((CDOMReference) list);
    }
    for (URI uri : edits.globalClearSet.getKeySet()) {
        for (CDOMObject owner : edits.globalClearSet.getSecondaryKeySet(uri)) {
            for (String tokenName : edits.globalClearSet.getTertiaryKeySet(uri, owner)) {
                for (CDOMReference<? extends CDOMList<?>> list : edits.globalClearSet.getListFor(uri, owner, tokenName)) {
                    commit.removeAllFromList(tokenName, owner, list);
                }
            }
        }
    }
    for (URI uri : edits.negativeMap.getKeySet()) {
        for (CDOMObject owner : edits.negativeMap.getSecondaryKeySet(uri)) {
            CDOMObject neg = edits.negativeMap.get(uri, owner);
            Collection<CDOMReference<? extends CDOMList<?>>> modifiedLists = neg.getModifiedLists();
            for (CDOMReference<? extends CDOMList<?>> list : modifiedLists) {
                //Note: Intentional Generics Violation due to Sun Compiler
                remove(owner, neg, (CDOMReference) list);
            }
        }
    }
    for (URI uri : edits.positiveMap.getKeySet()) {
        for (CDOMObject owner : edits.positiveMap.getSecondaryKeySet(uri)) {
            CDOMObject neg = edits.positiveMap.get(uri, owner);
            Collection<CDOMReference<? extends CDOMList<?>>> modifiedLists = neg.getModifiedLists();
            for (CDOMReference<? extends CDOMList<?>> list : modifiedLists) {
                //Note: Intentional Generics Violation due to Sun Compiler
                add(owner, neg, (CDOMReference) list);
            }
        }
    }
    for (String token : edits.masterAllClear.getKeySet()) {
        for (OwnerURI ou : edits.masterAllClear.getListFor(token)) {
            commit.clearAllMasterLists(token, ou.owner);
        }
    }
    rollback();
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject) CDOMList(pcgen.cdom.base.CDOMList) URI(java.net.URI) CDOMReference(pcgen.cdom.base.CDOMReference)

Example 69 with CDOMObject

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

the class AbilityTokenTest method testRoundRobinWithEqualType.

@Test
public void testRoundRobinWithEqualType() throws PersistenceLayerException {
    if (isTypeLegal()) {
        construct(primaryContext, "TestWP1");
        construct(primaryContext, "TestWP2");
        construct(secondaryContext, "TestWP1");
        construct(secondaryContext, "TestWP2");
        CDOMObject a = construct(primaryContext, "Typed1");
        a.addToListFor(ListKey.TYPE, Type.getConstant("OtherTestType"));
        CDOMObject b = construct(secondaryContext, "Typed1");
        b.addToListFor(ListKey.TYPE, Type.getConstant("OtherTestType"));
        CDOMObject c = construct(primaryContext, "Typed2");
        c.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
        CDOMObject d = construct(secondaryContext, "Typed2");
        d.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
        runRoundRobin(getSubTokenName() + '|' + "FEAT|NORMAL|TestWP1" + getJoinCharacter() + "TestWP2" + getJoinCharacter() + "TYPE=OtherTestType" + getJoinCharacter() + "TYPE=TestType");
    }
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject) Test(org.junit.Test)

Example 70 with CDOMObject

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

the class AbilityTokenTest method testValidInputTypeDot.

@Test
public void testValidInputTypeDot() throws PersistenceLayerException {
    if (isTypeLegal()) {
        CDOMObject a = construct(primaryContext, "TestWP1");
        a.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
        CDOMObject b = construct(secondaryContext, "TestWP1");
        b.addToListFor(ListKey.TYPE, Type.getConstant("TestType"));
        assertTrue(parse(getSubTokenName() + '|' + "FEAT|NORMAL|TYPE.TestType"));
        assertCleanConstruction();
    }
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject) Test(org.junit.Test)

Aggregations

CDOMObject (pcgen.cdom.base.CDOMObject)235 Test (org.junit.Test)68 CharID (pcgen.cdom.enumeration.CharID)53 PCTemplate (pcgen.core.PCTemplate)30 ArrayList (java.util.ArrayList)22 PCClass (pcgen.core.PCClass)18 DataFacetChangeEvent (pcgen.cdom.facet.event.DataFacetChangeEvent)17 Race (pcgen.core.Race)17 Equipment (pcgen.core.Equipment)15 PlayerCharacter (pcgen.core.PlayerCharacter)15 Map (java.util.Map)14 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)14 CDOMReference (pcgen.cdom.base.CDOMReference)14 BonusObj (pcgen.core.bonus.BonusObj)14 IdentityHashMap (java.util.IdentityHashMap)12 Set (java.util.Set)12 VariableKey (pcgen.cdom.enumeration.VariableKey)11 HashMap (java.util.HashMap)10 CNAbility (pcgen.cdom.content.CNAbility)10 Spell (pcgen.core.spell.Spell)9