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

Method unparse

code/src/java/plugin/lsttokens/equipment/EqmodToken.java:122–163  ·  view source on GitHub ↗
(LoadContext context, Equipment eq)

Source from the content-addressed store, hash-verified

120 }
121
122 @Override
123 public String[] unparse(LoadContext context, Equipment eq)
124 {
125 AbstractObjectContext obj = context.getObjectContext();
126 String damage = obj.getString(eq, StringKey.DAMAGE_OVERRIDE);
127 Set<String> set = new TreeSet<>();
128 if (damage != null)
129 {
130 set.add(EQMOD_DAMAGE + Constants.PIPE + damage);
131 }
132 BigDecimal weight = obj.getObject(eq, ObjectKey.WEIGHT_MOD);
133 if (weight != null)
134 {
135 set.add(EQMOD_WEIGHT + Constants.PIPE + weight.toString().replace('.', ','));
136 }
137 EquipmentHead head = eq.getEquipmentHeadReference(1);
138 if (head != null)
139 {
140 Changes<EqModRef> changes = obj.getListChanges(head, ListKey.EQMOD_INFO);
141 Collection<EqModRef> added = changes.getAdded();
142 if (added != null)
143 {
144 for (EqModRef modRef : added)
145 {
146 String key = modRef.getRef().getLSTformat(false);
147 StringBuilder sb = new StringBuilder();
148 sb.append(key);
149 for (String s : modRef.getChoices())
150 {
151 sb.append(Constants.PIPE);
152 sb.append(s.replace('|', '='));
153 }
154 set.add(sb.toString());
155 }
156 }
157 }
158 if (set.isEmpty())
159 {
160 return null;
161 }
162 return new String[]{StringUtil.join(set, Constants.DOT)};
163 }
164
165 @Override
166 public Class<Equipment> getTokenClass()

Callers

nothing calls this directly

Calls 15

getStringMethod · 0.95
getObjectMethod · 0.95
getListChangesMethod · 0.95
joinMethod · 0.95
getObjectContextMethod · 0.65
addMethod · 0.65
toStringMethod · 0.65
getAddedMethod · 0.65
getLSTformatMethod · 0.65
getChoicesMethod · 0.65
isEmptyMethod · 0.65

Tested by

no test coverage detected