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

Method unparse

code/src/java/plugin/lsttokens/add/TemplateToken.java:121–161  ·  view source on GitHub ↗
(LoadContext context, CDOMObject obj)

Source from the content-addressed store, hash-verified

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