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

Method unparse

code/src/java/plugin/lsttokens/add/SkillToken.java:145–189  ·  view source on GitHub ↗
(LoadContext context, CDOMObject obj)

Source from the content-addressed store, hash-verified

143 }
144
145 @Override
146 public String[] unparse(LoadContext context, CDOMObject obj)
147 {
148 Changes<PersistentTransitionChoice<?>> grantChanges =
149 context.getObjectContext().getListChanges(obj, ListKey.ADD);
150 Collection<PersistentTransitionChoice<?>> addedItems = grantChanges.getAdded();
151 if (addedItems == null || addedItems.isEmpty())
152 {
153 // Zero indicates no Token
154 return null;
155 }
156 List<String> addStrings = new ArrayList<>();
157 for (TransitionChoice<?> container : addedItems)
158 {
159 SelectableSet<?> cs = container.getChoices();
160 if (getTokenName().equals(cs.getName()) && SKILL_CLASS.equals(cs.getChoiceClass()))
161 {
162 Formula f = container.getCount();
163 if (f == null)
164 {
165 context.addWriteMessage("Unable to find " + getFullName() + " Count");
166 return null;
167 }
168 if (f.isStatic() && f.resolveStatic().doubleValue() <= 0)
169 {
170 context.addWriteMessage("Count in " + getFullName() + " must be > 0");
171 return null;
172 }
173 if (!cs.getGroupingState().isValid())
174 {
175 context.addWriteMessage("Non-sensical " + getFullName()
176 + ": Contains ANY and a specific reference: " + cs.getLSTformat());
177 return null;
178 }
179 StringBuilder sb = new StringBuilder();
180 if (!FormulaFactory.ONE.equals(f))
181 {
182 sb.append(f).append(Constants.PIPE);
183 }
184 sb.append(cs.getLSTformat());
185 addStrings.add(sb.toString());
186 }
187 }
188 return addStrings.toArray(new String[0]);
189 }
190
191 @Override
192 public Class<CDOMObject> getTokenClass()

Callers

nothing calls this directly

Calls 15

getTokenNameMethod · 0.95
getFullNameMethod · 0.95
isStaticMethod · 0.95
resolveStaticMethod · 0.95
doubleValueMethod · 0.80
getListChangesMethod · 0.65
getObjectContextMethod · 0.65
getAddedMethod · 0.65
isEmptyMethod · 0.65
getChoicesMethod · 0.65
equalsMethod · 0.65
getNameMethod · 0.65

Tested by

no test coverage detected