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

Method unparse

code/src/java/plugin/lsttokens/race/FavclassToken.java:124–177  ·  view source on GitHub ↗
(LoadContext context, Race race)

Source from the content-addressed store, hash-verified

122 }
123
124 @Override
125 public String[] unparse(LoadContext context, Race race)
126 {
127 Changes<CDOMReference<? extends PCClass>> changes =
128 context.getObjectContext().getListChanges(race, ListKey.FAVORED_CLASS);
129 Changes<ChooseSelectionActor<?>> listChanges =
130 context.getObjectContext().getListChanges(race, ListKey.NEW_CHOOSE_ACTOR);
131 Boolean anyfavored = context.getObjectContext().getObject(race, ObjectKey.ANY_FAVORED_CLASS);
132 SortedSet<String> set = new TreeSet<>();
133 if (anyfavored != null && anyfavored)
134 {
135 set.add(Constants.HIGHEST_LEVEL_CLASS);
136 }
137 if (changes != null && !changes.isEmpty() && changes.hasAddedItems())
138 {
139 for (CDOMReference<? extends PCClass> ref : changes.getAdded())
140 {
141 String prefix = ref.getPersistentFormat();
142 if (prefix.startsWith("SUBCLASS="))
143 {
144 set.add(prefix.substring(9) + Constants.DOT + ref.getLSTformat(false));
145 }
146 else
147 {
148 set.add(ref.getLSTformat(false));
149 }
150 }
151 }
152 Collection<ChooseSelectionActor<?>> listAdded = listChanges.getAdded();
153 if (listAdded != null && !listAdded.isEmpty())
154 {
155 for (ChooseSelectionActor<?> cra : listAdded)
156 {
157 if (cra.getSource().equals(getTokenName()))
158 {
159 try
160 {
161 set.add(cra.getLstFormat());
162 }
163 catch (PersistenceLayerException e)
164 {
165 context.addWriteMessage("Error writing Prerequisite: " + e);
166 return null;
167 }
168 }
169 }
170 }
171 if (set.isEmpty())
172 {
173 // Zero indicates no add or clear
174 return null;
175 }
176 return new String[]{StringUtil.join(set, Constants.PIPE)};
177 }
178
179 @Override
180 public Class<Race> getTokenClass()

Callers

nothing calls this directly

Calls 15

getTokenNameMethod · 0.95
joinMethod · 0.95
getListChangesMethod · 0.65
getObjectContextMethod · 0.65
getObjectMethod · 0.65
addMethod · 0.65
isEmptyMethod · 0.65
hasAddedItemsMethod · 0.65
getAddedMethod · 0.65
getPersistentFormatMethod · 0.65
getLSTformatMethod · 0.65
equalsMethod · 0.65

Tested by

no test coverage detected