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

Method unparse

code/src/java/plugin/lsttokens/CcskillLst.java:165–224  ·  view source on GitHub ↗
(LoadContext context, CDOMObject obj)

Source from the content-addressed store, hash-verified

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

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