MCPcopy Create free account
hub / github.com/PCGen/pcgen / unparse

Method unparse

code/src/java/plugin/lsttokens/CskillLst.java:167–226  ·  view source on GitHub ↗
(LoadContext context, CDOMObject obj)

Source from the content-addressed store, hash-verified

165 }
166
167 @Override
168 public String[] unparse(LoadContext context, CDOMObject obj)
169 {
170 Changes<CDOMReference<Skill>> changes = context.getObjectContext().getListChanges(obj, ListKey.CSKILL);
171 Changes<ChooseSelectionActor<?>> listChanges =
172 context.getObjectContext().getListChanges(obj, ListKey.NEW_CHOOSE_ACTOR);
173 List<String> list = new ArrayList<>();
174 Collection<CDOMReference<Skill>> removedItems = changes.getRemoved();
175 if (removedItems != null && !removedItems.isEmpty())
176 {
177 if (changes.includesGlobalClear())
178 {
179 context.addWriteMessage(
180 "Non-sensical relationship in " + getTokenName() + ": global .CLEAR and local .CLEAR. performed");
181 return null;
182 }
183 list.add(Constants.LST_DOT_CLEAR_DOT + ReferenceUtilities.joinLstFormat(removedItems, "|.CLEAR."));
184 }
185 Collection<ChooseSelectionActor<?>> listRemoved = listChanges.getRemoved();
186 if (listRemoved != null && !listRemoved.isEmpty())
187 {
188 if (listRemoved.contains(this))
189 {
190 list.add(".CLEAR.LIST");
191 }
192 }
193 if (changes.includesGlobalClear())
194 {
195 list.add(Constants.LST_DOT_CLEAR);
196 }
197 Collection<CDOMReference<Skill>> added = changes.getAdded();
198 if (added != null && !added.isEmpty())
199 {
200 list.add(ReferenceUtilities.joinLstFormat(added, Constants.PIPE));
201 }
202 Collection<ChooseSelectionActor<?>> listAdded = listChanges.getAdded();
203 if (listAdded != null && !listAdded.isEmpty())
204 {
205 for (ChooseSelectionActor<?> cra : listAdded)
206 {
207 if (cra.getSource().equals(SOURCE))
208 {
209 try
210 {
211 list.add(cra.getLstFormat());
212 }
213 catch (PersistenceLayerException e)
214 {
215 context.addWriteMessage("Error writing Prerequisite: " + e);
216 return null;
217 }
218 }
219 }
220 }
221 if (list.isEmpty())
222 {
223 return null;
224 }

Callers

nothing calls this directly

Calls 15

getTokenNameMethod · 0.95
joinLstFormatMethod · 0.95
getListChangesMethod · 0.65
getObjectContextMethod · 0.65
getRemovedMethod · 0.65
isEmptyMethod · 0.65
includesGlobalClearMethod · 0.65
addWriteMessageMethod · 0.65
addMethod · 0.65
containsMethod · 0.65
getAddedMethod · 0.65
equalsMethod · 0.65

Tested by

no test coverage detected