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

Class HitDieLock

code/src/java/pcgen/cdom/processor/HitDieLock.java:31–108  ·  view source on GitHub ↗

A HitDieLock represents a constrained HitDie that does not change. Since this acts as a Processor, the effect of the application of this Processor is unconditional return of the HitDie object provided at construction of the HitDieLock object.

Source from the content-addressed store, hash-verified

29 * HitDieLock object.
30 */
31public class HitDieLock implements Processor<HitDie>
32{
33
34 /**
35 * The HitDie to which this HitDieLock is "locked"
36 */
37 private final HitDie hitDie;
38
39 /**
40 * Constructs a new HitDieLock which will unconditionally return the given
41 * HitDie object.
42 *
43 * @param die
44 * The HitDie for this HitDieLock
45 * @throws IllegalArgumentException
46 * if the given HitDie is null
47 */
48 public HitDieLock(HitDie die)
49 {
50 Objects.requireNonNull(die, "Die for HitDieLock cannot be null");
51 hitDie = die;
52 }
53
54 /**
55 * Applies this Processor by returning the HitDie to which this HitDieLock is
56 * set.
57 *
58 * Since HitDieLock is universal, the given context is ignored.
59 *
60 * @param origHD
61 * The input HitDie this Processor will act upon
62 * @param context
63 * The context of this Processor, ignored by HitDieLock.
64 * @return The modified object, of the same class as the input object.
65 */
66 @Override
67 public HitDie applyProcessor(HitDie origHD, Object context)
68 {
69 return hitDie;
70 }
71
72 /**
73 * Returns a representation of this HitDieLock, suitable for storing in an
74 * LST file.
75 *
76 * @return A representation of this HitDieLock, suitable for storing in an
77 * LST file.
78 */
79 @Override
80 public String getLSTformat()
81 {
82 return Integer.toString(hitDie.getDie());
83 }
84
85 /**
86 * The class of object this Processor acts upon (HitDie).
87 *
88 * @return The class of object this Processor acts upon (HitDie.class)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected