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

Method unparse

code/src/java/plugin/lsttokens/add/LanguageToken.java:136–182  ·  view source on GitHub ↗
(LoadContext context, CDOMObject obj)

Source from the content-addressed store, hash-verified

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