(LoadContext context, Spell spell)
| 207 | } |
| 208 | |
| 209 | @Override |
| 210 | public String[] unparse(LoadContext context, Spell spell) |
| 211 | { |
| 212 | DoubleKeyMapToList<Prerequisite, Integer, CDOMReference<DomainSpellList>> dkmtl = new DoubleKeyMapToList<>(); |
| 213 | List<String> list = new ArrayList<>(); |
| 214 | Changes<CDOMReference<DomainSpellList>> masterChanges = |
| 215 | context.getListContext().getMasterListChanges(getTokenName(), spell, SPELLLIST_CLASS); |
| 216 | if (masterChanges.includesGlobalClear()) |
| 217 | { |
| 218 | list.add(Constants.LST_DOT_CLEAR_ALL); |
| 219 | } |
| 220 | if (masterChanges.hasRemovedItems()) |
| 221 | { |
| 222 | for (CDOMReference<DomainSpellList> swl : masterChanges.getRemoved()) |
| 223 | { |
| 224 | AssociatedChanges<Spell> changes = |
| 225 | context.getListContext().getChangesInMasterList(getTokenName(), spell, swl); |
| 226 | MapToList<Spell, AssociatedPrereqObject> map = changes.getRemovedAssociations(); |
| 227 | if (map != null && !map.isEmpty()) |
| 228 | { |
| 229 | for (Spell added : map.getKeySet()) |
| 230 | { |
| 231 | if (!spell.getKeyName().equals(added.getKeyName())) |
| 232 | { |
| 233 | context.addWriteMessage("Spell " + getTokenName() + " token cannot remove another Spell " |
| 234 | + "(must only remove itself)"); |
| 235 | return null; |
| 236 | } |
| 237 | for (AssociatedPrereqObject assoc : map.getListFor(added)) |
| 238 | { |
| 239 | List<Prerequisite> prereqs = assoc.getPrerequisiteList(); |
| 240 | if (prereqs != null && !prereqs.isEmpty()) |
| 241 | { |
| 242 | context.addWriteMessage("Incoming Remove " + "Edge to " + spell.getKeyName() + " had a " |
| 243 | + "Prerequisite: " + prereqs.size()); |
| 244 | return null; |
| 245 | } |
| 246 | dkmtl.addToListFor(null, -1, swl); |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | for (CDOMReference<DomainSpellList> swl : masterChanges.getAdded()) |
| 253 | { |
| 254 | AssociatedChanges<Spell> changes = |
| 255 | context.getListContext().getChangesInMasterList(getTokenName(), spell, swl); |
| 256 | Collection<Spell> removedItems = changes.getRemoved(); |
| 257 | if (removedItems != null && !removedItems.isEmpty() || changes.includesGlobalClear()) |
| 258 | { |
| 259 | context.addWriteMessage(getTokenName() + " does not support .CLEAR."); |
| 260 | return null; |
| 261 | } |
| 262 | MapToList<Spell, AssociatedPrereqObject> map = changes.getAddedAssociations(); |
| 263 | if (map != null && !map.isEmpty()) |
| 264 | { |
| 265 | for (Spell added : map.getKeySet()) |
| 266 | { |
nothing calls this directly
no test coverage detected