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

Class ChangeArmorType

code/src/java/pcgen/cdom/processor/ChangeArmorType.java:38–195  ·  view source on GitHub ↗

ChangeArmorType is a Processor that alters Armor Types. If the type to be modified matches the source type of the ChangeArmorType object, then the result type is returned. Otherwise, the incoming type is not modified. NOTE: It is possible (albeit strange) to use ChangeArmorType as a "RemoveArmorTy

Source from the content-addressed store, hash-verified

36 * should expect that applyProcessor(String, Object) may return null.
37 */
38public class ChangeArmorType implements Processor<String>
39{
40
41 /**
42 * The source type for this ChangeArmorType. If the type to be modified
43 * matches the source type of the ChangeArmorType object, then this Processor
44 * will act on the incoming type.
45 */
46 private final String source;
47
48 /**
49 * The result type for this ChangeArmorType. If the Processor acts on the
50 * incoming type, it will return this type in place of the incoming type.
51 */
52 private final String result;
53
54 /**
55 * Constructs a new ChangeArmorType with the given source and result types.
56 *
57 * @param sourceType
58 * The source type for this ChangeArmorType, to be tested against
59 * the types provided in applyProcessor
60 * @param resultType
61 * The result type for this ChangeArmorType, to be returned from
62 * applyProcessor if the Processor acts on the incoming type. May
63 * be null to indicate this ChangeArmorType should remove the
64 * source armor type
65 * @throws IllegalArgumentException
66 * if the given source type is null
67 */
68 public ChangeArmorType(String sourceType, String resultType)
69 {
70 Objects.requireNonNull(sourceType, "Source Type for ChangeArmorType cannot be null");
71 Objects.requireNonNull(resultType, "Resulting Type for ChangeArmorType cannot be null");
72 result = resultType;
73 source = sourceType;
74 }
75
76 /**
77 * Applies this Processor to the given input armor type.
78 *
79 * If the type to be modified matches the source type of the ChangeArmorType
80 * object, then the result type is returned. Otherwise, the incoming type is
81 * not modified (and the incoming type is returned).
82 *
83 * Since ChangeArmorType is universal, the given context is ignored.
84 *
85 * NOTE: It is possible (albeit strange) to use ChangeArmorType as a
86 * "RemoveArmorType", in that the result type can be null. Therefore, users
87 * should account for the possibility that this method may return null.
88 *
89 * @param sourceType
90 * The input armor type this Processor will act upon
91 * @param context
92 * The context of this Processor, ignored by ChangeArmorType.
93 * @return The modified armor type, if the type to be modified matches the
94 * source type of the ChangeArmorType object; otherwise the source
95 * armor type

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected