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

Method unparse

code/src/java/plugin/lsttokens/TypeLst.java:134–179  ·  view source on GitHub ↗
(LoadContext context, CDOMObject cdo)

Source from the content-addressed store, hash-verified

132 }
133
134 @Override
135 public String[] unparse(LoadContext context, CDOMObject cdo)
136 {
137 if (cdo instanceof CompanionMod)
138 {
139 // TYPEs for companionmods are processed by plugin.lsttokens.companionmod.TypeToken
140 return null;
141 }
142 Changes<Type> changes = context.getObjectContext().getListChanges(cdo, ListKey.TYPE);
143 if (changes == null || changes.isEmpty())
144 {
145 return null;
146 }
147 StringBuilder sb = new StringBuilder();
148 Collection<?> added = changes.getAdded();
149 boolean globalClear = changes.includesGlobalClear();
150 if (globalClear)
151 {
152 sb.append(Constants.LST_DOT_CLEAR);
153 }
154 if (added != null && !added.isEmpty())
155 {
156 if (globalClear)
157 {
158 sb.append(Constants.DOT);
159 }
160 sb.append(StringUtil.join(added, Constants.DOT));
161 }
162 Collection<Type> removed = changes.getRemoved();
163 if (removed != null && !removed.isEmpty())
164 {
165 if (sb.length() > 0)
166 {
167 sb.append(Constants.DOT);
168 }
169 sb.append("REMOVE.");
170 sb.append(StringUtil.join(removed, Constants.DOT));
171 }
172 if (sb.length() == 0)
173 {
174 context.addWriteMessage(
175 getTokenName() + " was expecting non-empty changes to include " + "added items or global clear");
176 return null;
177 }
178 return new String[]{sb.toString()};
179 }
180
181 @Override
182 public Class<CDOMObject> getTokenClass()

Callers

nothing calls this directly

Calls 11

joinMethod · 0.95
getTokenNameMethod · 0.95
getListChangesMethod · 0.65
getObjectContextMethod · 0.65
isEmptyMethod · 0.65
getAddedMethod · 0.65
includesGlobalClearMethod · 0.65
getRemovedMethod · 0.65
addWriteMessageMethod · 0.65
toStringMethod · 0.65
appendMethod · 0.45

Tested by

no test coverage detected