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

Method unparse

code/src/java/plugin/lsttokens/VisionLst.java:164–214  ·  view source on GitHub ↗
(LoadContext context, CDOMObject obj)

Source from the content-addressed store, hash-verified

162 }
163
164 @Override
165 public String[] unparse(LoadContext context, CDOMObject obj)
166 {
167 AssociatedChanges<CDOMReference<Vision>> changes =
168 context.getListContext().getChangesInList(getTokenName(), obj, Vision.VISIONLIST);
169 List<String> list = new ArrayList<>();
170 Collection<CDOMReference<Vision>> removedItems = changes.getRemoved();
171 if (changes.includesGlobalClear())
172 {
173 if (removedItems != null && !removedItems.isEmpty())
174 {
175 context.addWriteMessage(
176 "Non-sensical relationship in " + getTokenName() + ": global .CLEAR and local .CLEAR. performed");
177 return null;
178 }
179 list.add(Constants.LST_DOT_CLEAR);
180 }
181 else if (removedItems != null && !removedItems.isEmpty())
182 {
183 list.add(Constants.LST_DOT_CLEAR_DOT + ReferenceUtilities.joinLstFormat(removedItems, "|.CLEAR."));
184 }
185 MapToList<CDOMReference<Vision>, AssociatedPrereqObject> mtl = changes.getAddedAssociations();
186 if (mtl != null && !mtl.isEmpty())
187 {
188 MapToList<Set<Prerequisite>, Vision> m = new HashMapToList<>();
189 for (CDOMReference<Vision> ab : mtl.getKeySet())
190 {
191 for (AssociatedPrereqObject assoc : mtl.getListFor(ab))
192 {
193 m.addAllToListFor(new HashSet<>(assoc.getPrerequisiteList()), ab.getContainedObjects());
194 }
195 }
196 Set<String> set = new TreeSet<>();
197 for (Set<Prerequisite> prereqs : m.getKeySet())
198 {
199 StringBuilder sb = new StringBuilder(StringUtil.join(m.getListFor(prereqs), Constants.PIPE));
200 if (prereqs != null && !prereqs.isEmpty())
201 {
202 sb.append(Constants.PIPE);
203 sb.append(getPrerequisiteString(context, prereqs));
204 }
205 set.add(sb.toString());
206 }
207 list.addAll(set);
208 }
209 if (list.isEmpty())
210 {
211 return null;
212 }
213 return list.toArray(new String[0]);
214 }
215
216 @Override
217 public Class<CDOMObject> getTokenClass()

Callers

nothing calls this directly

Calls 15

getTokenNameMethod · 0.95
joinLstFormatMethod · 0.95
joinMethod · 0.95
getChangesInListMethod · 0.65
getListContextMethod · 0.65
getRemovedMethod · 0.65
includesGlobalClearMethod · 0.65
isEmptyMethod · 0.65
addWriteMessageMethod · 0.65
addMethod · 0.65
getAddedAssociationsMethod · 0.65
getKeySetMethod · 0.65

Tested by

no test coverage detected