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

Method unparse

code/src/java/plugin/lsttokens/ability/BenefitToken.java:117–158  ·  view source on GitHub ↗
(LoadContext context, Ability ability)

Source from the content-addressed store, hash-verified

115 }
116
117 @Override
118 public String[] unparse(LoadContext context, Ability ability)
119 {
120 PatternChanges<Description> changes =
121 context.getObjectContext().getListPatternChanges(ability, ListKey.BENEFIT);
122 if (changes == null || changes.isEmpty())
123 {
124 return null;
125 }
126 List<String> list = new ArrayList<>();
127 Collection<String> removedItems = changes.getRemoved();
128 if (changes.includesGlobalClear())
129 {
130 if (removedItems != null && !removedItems.isEmpty())
131 {
132 context.addWriteMessage(
133 "Non-sensical relationship in " + getTokenName() + ": global .CLEAR and local .CLEAR. performed");
134 return null;
135 }
136 list.add(Constants.LST_DOT_CLEAR);
137 }
138 else if (removedItems != null && !removedItems.isEmpty())
139 {
140 for (String d : removedItems)
141 {
142 list.add(Constants.LST_DOT_CLEAR_DOT + d);
143 }
144 }
145 Collection<Description> added = changes.getAdded();
146 if (added != null && !added.isEmpty())
147 {
148 for (Description d : added)
149 {
150 list.add(d.getPCCText());
151 }
152 }
153 if (list.isEmpty())
154 {
155 return null;
156 }
157 return list.toArray(new String[0]);
158 }
159
160 @Override
161 public Class<Ability> getTokenClass()

Callers

nothing calls this directly

Calls 11

getTokenNameMethod · 0.95
getListPatternChangesMethod · 0.65
getObjectContextMethod · 0.65
isEmptyMethod · 0.65
getRemovedMethod · 0.65
includesGlobalClearMethod · 0.65
addWriteMessageMethod · 0.65
addMethod · 0.65
getAddedMethod · 0.65
getPCCTextMethod · 0.45
toArrayMethod · 0.45

Tested by

no test coverage detected