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

Class FixedSizeFormula

code/src/java/pcgen/cdom/formula/FixedSizeFormula.java:35–161  ·  view source on GitHub ↗

A FixedSizeFormula is a Formula that returns a deterministic value, used to uniquely identify a SizeAdjustment. The SizeAdjustment for which this Formula will return the value must be defined during construction of the FixedSizeFormula.

Source from the content-addressed store, hash-verified

33 * FixedSizeFormula.
34 */
35public class FixedSizeFormula implements Formula
36{
37
38 /**
39 * The underlying SizeAdjustment for which this Formula will return the
40 * identifying value.
41 */
42 private final CDOMSingleRef<SizeAdjustment> size;
43
44 /**
45 * Creates a new FixedSizeFormula for the given SizeAdjustment.
46 *
47 * @param sAdj
48 * The SizeAdjustment for which this Formula will return the
49 * identifying value.
50 * @throws IllegalArgumentException
51 * if the given SizeAdjustment is null
52 */
53 public FixedSizeFormula(CDOMSingleRef<SizeAdjustment> sAdj)
54 {
55 Objects.requireNonNull(sAdj, "Size Adjustment for FixedSizeFormula cannot be null");
56 size = sAdj;
57 }
58
59 /**
60 * Returns a String representation of this FixedSizeFormula, primarily for
61 * purposes of debugging. It is strongly advised that no dependency on this
62 * method be created, as the return value may be changed without warning.
63 */
64 @Override
65 public String toString()
66 {
67 return size.getLSTformat(false);
68 }
69
70 @Override
71 public int hashCode()
72 {
73 return size.hashCode();
74 }
75
76 @Override
77 public boolean equals(Object obj)
78 {
79 return obj instanceof FixedSizeFormula && size.equals(((FixedSizeFormula) obj).size);
80 }
81
82 /**
83 * Resolves to the identifying value of the SizeAdjustment provided during
84 * construction of the FixedSizeFormula. The given PlayerCharacter and
85 * source are ignored.
86 *
87 * @param pc
88 * The PlayerCharacter relative to which the FixedSizeFormula
89 * should be resolved (ignored)
90 * @param source
91 * The source object of the FixedSizeFormula, for purposes of
92 * resolution (ignored)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected