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

Method unparse

code/src/java/plugin/lsttokens/domain/CskillToken.java:159–218  ·  view source on GitHub ↗
(LoadContext context, Domain obj)

Source from the content-addressed store, hash-verified

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

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