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

Method unparse

code/src/java/plugin/lsttokens/add/EquipToken.java:131–171  ·  view source on GitHub ↗
(LoadContext context, CDOMObject obj)

Source from the content-addressed store, hash-verified

129 }
130
131 @Override
132 public String[] unparse(LoadContext context, CDOMObject obj)
133 {
134 Changes<PersistentTransitionChoice<?>> grantChanges =
135 context.getObjectContext().getListChanges(obj, ListKey.ADD);
136 Collection<PersistentTransitionChoice<?>> addedItems = grantChanges.getAdded();
137 if (addedItems == null || addedItems.isEmpty())
138 {
139 // Zero indicates no Token
140 return null;
141 }
142 List<String> addStrings = new ArrayList<>();
143 for (TransitionChoice<?> container : addedItems)
144 {
145 SelectableSet<?> cs = container.getChoices();
146 if (EQUIPMENT_CLASS.equals(cs.getChoiceClass()))
147 {
148 Formula f = container.getCount();
149 if (f == null)
150 {
151 context.addWriteMessage("Unable to find " + getFullName() + " Count");
152 return null;
153 }
154 if (f.isStatic() && f.resolveStatic().doubleValue() <= 0)
155 {
156 context.addWriteMessage("Count in " + getFullName() + " must be > 0");
157 return null;
158 }
159 StringBuilder sb = new StringBuilder();
160 if (!FormulaFactory.ONE.equals(f))
161 {
162 sb.append(f).append(Constants.PIPE);
163 }
164 sb.append(cs.getLSTformat());
165 addStrings.add(sb.toString());
166
167 // assoc.getAssociation(AssociationKey.CHOICE_MAXCOUNT);
168 }
169 }
170 return addStrings.toArray(new String[0]);
171 }
172
173 @Override
174 public Class<CDOMObject> getTokenClass()

Callers

nothing calls this directly

Calls 15

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
getChoiceClassMethod · 0.65
getCountMethod · 0.65

Tested by

no test coverage detected