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

Method unparse

code/src/java/plugin/lsttokens/auto/ArmorProfToken.java:193–253  ·  view source on GitHub ↗
(LoadContext context, CDOMObject obj)

Source from the content-addressed store, hash-verified

191 }
192
193 @Override
194 public String[] unparse(LoadContext context, CDOMObject obj)
195 {
196 Changes<ArmorProfProvider> changes = context.getObjectContext().getListChanges(obj, ListKey.AUTO_ARMORPROF);
197 Changes<ChooseSelectionActor<?>> listChanges =
198 context.getObjectContext().getListChanges(obj, ListKey.NEW_CHOOSE_ACTOR);
199 Collection<ArmorProfProvider> added = changes.getAdded();
200 Set<String> set = new TreeSet<>();
201 Collection<ChooseSelectionActor<?>> listAdded = listChanges.getAdded();
202 boolean foundAny = false;
203 boolean foundOther = false;
204 if (listAdded != null && !listAdded.isEmpty())
205 {
206 for (ChooseSelectionActor<?> cra : listAdded)
207 {
208 if (cra.getSource().equals(getTokenName()))
209 {
210 try
211 {
212 set.add(cra.getLstFormat());
213 foundOther = true;
214 }
215 catch (PersistenceLayerException e)
216 {
217 context.addWriteMessage("Error writing Prerequisite: " + e);
218 return null;
219 }
220 }
221 }
222 }
223 if (added != null)
224 {
225 for (ArmorProfProvider spp : added)
226 {
227 StringBuilder sb = new StringBuilder();
228 sb.append(spp.getLstFormat());
229 if (spp.hasPrerequisites())
230 {
231 sb.append('|');
232 sb.append(getPrerequisiteString(context, spp.getPrerequisiteList()));
233 }
234 String ab = sb.toString();
235 boolean isUnconditionalAll = Constants.LST_ALL.equals(ab);
236 foundAny |= isUnconditionalAll;
237 foundOther |= !isUnconditionalAll;
238 set.add(ab);
239 }
240 }
241 if (foundAny && foundOther)
242 {
243 context
244 .addWriteMessage("Non-sensical " + getFullName() + ": Contains ANY and a specific reference: " + set);
245 return null;
246 }
247 if (set.isEmpty())
248 {
249 //okay
250 return null;

Callers

nothing calls this directly

Calls 15

getTokenNameMethod · 0.95
getFullNameMethod · 0.95
getListChangesMethod · 0.65
getObjectContextMethod · 0.65
getAddedMethod · 0.65
isEmptyMethod · 0.65
equalsMethod · 0.65
getSourceMethod · 0.65
addMethod · 0.65
getLstFormatMethod · 0.65
addWriteMessageMethod · 0.65
hasPrerequisitesMethod · 0.65

Tested by

no test coverage detected