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

Method unparse

code/src/java/plugin/lsttokens/BonusLst.java:83–116  ·  view source on GitHub ↗
(LoadContext context, CDOMObject obj)

Source from the content-addressed store, hash-verified

81 }
82
83 @Override
84 public String[] unparse(LoadContext context, CDOMObject obj)
85 {
86 if (obj instanceof EquipmentModifier)
87 {
88 // EquipmentModifier bonuses are handled by plugin.lsttokens.equipmentmodifier.BonusToken
89 return null;
90 }
91
92 Changes<BonusObj> changes = context.getObjectContext().getListChanges(obj, ListKey.BONUS);
93 if (changes == null || changes.isEmpty())
94 {
95 // Empty indicates no token present
96 return null;
97 }
98 // CONSIDER need to deal with removed...
99 Collection<BonusObj> added = changes.getAdded();
100 String tokenName = getTokenName();
101 Set<String> bonusSet = new TreeSet<>();
102 for (BonusObj bonus : added)
103 {
104 if (tokenName.equals(bonus.getTokenSource()))
105 {
106 String bonusString = bonus.getLSTformat();
107 bonusSet.add(bonusString);
108 }
109 }
110 if (bonusSet.isEmpty())
111 {
112 // This is okay - just no BONUSes from this token
113 return null;
114 }
115 return bonusSet.toArray(new String[0]);
116 }
117
118 @Override
119 public Class<CDOMObject> getTokenClass()

Callers

nothing calls this directly

Calls 10

getTokenNameMethod · 0.95
getTokenSourceMethod · 0.80
getListChangesMethod · 0.65
getObjectContextMethod · 0.65
isEmptyMethod · 0.65
getAddedMethod · 0.65
equalsMethod · 0.65
getLSTformatMethod · 0.65
addMethod · 0.65
toArrayMethod · 0.45

Tested by

no test coverage detected