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

Method unparse

code/src/java/plugin/lsttokens/DrLst.java:106–138  ·  view source on GitHub ↗
(LoadContext context, CDOMObject obj)

Source from the content-addressed store, hash-verified

104 }
105
106 @Override
107 public String[] unparse(LoadContext context, CDOMObject obj)
108 {
109 Changes<DamageReduction> changes = context.getObjectContext().getListChanges(obj, ListKey.DAMAGE_REDUCTION);
110 Collection<DamageReduction> added = changes.getAdded();
111 List<String> list = new ArrayList<>();
112 if (changes.includesGlobalClear())
113 {
114 list.add(Constants.LST_DOT_CLEAR);
115 }
116 else if (added == null || added.isEmpty())
117 {
118 // Zero indicates no Token (and no global clear, so nothing to do)
119 return null;
120 }
121 Set<String> set = new TreeSet<>();
122 if (added != null)
123 {
124 for (DamageReduction lw : added)
125 {
126 StringBuilder sb = new StringBuilder();
127 sb.append(lw.getLSTformat());
128 if (lw.hasPrerequisites())
129 {
130 sb.append(Constants.PIPE);
131 sb.append(context.getPrerequisiteString(lw.getPrerequisiteList()));
132 }
133 set.add(sb.toString());
134 }
135 }
136 list.addAll(set);
137 return list.toArray(new String[0]);
138 }
139
140 @Override
141 public Class<CDOMObject> getTokenClass()

Callers

nothing calls this directly

Calls 14

getListChangesMethod · 0.65
getObjectContextMethod · 0.65
getAddedMethod · 0.65
includesGlobalClearMethod · 0.65
addMethod · 0.65
isEmptyMethod · 0.65
getLSTformatMethod · 0.65
hasPrerequisitesMethod · 0.65
getPrerequisiteStringMethod · 0.65
getPrerequisiteListMethod · 0.65
toStringMethod · 0.65
addAllMethod · 0.65

Tested by

no test coverage detected