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