An CNAbility represents an "unresolved" (categorized) Ability & Nature.
| 39 | * An CNAbility represents an "unresolved" (categorized) Ability & Nature. |
| 40 | */ |
| 41 | public class CNAbility extends ConcretePrereqObject |
| 42 | implements QualifyingObject, Comparable<CNAbility>, ChooseDriver, Reducible |
| 43 | { |
| 44 | |
| 45 | private final Category<Ability> category; |
| 46 | |
| 47 | /** |
| 48 | * The Ability that this CNAbility represents |
| 49 | */ |
| 50 | private final Ability ability; |
| 51 | |
| 52 | /** |
| 53 | * The Nature of the Ability |
| 54 | */ |
| 55 | private final Nature nature; |
| 56 | |
| 57 | /** |
| 58 | * Creates a new CNAbility for the given Ability. |
| 59 | * |
| 60 | * @param abil |
| 61 | * The Ability which this CNAbility will contain |
| 62 | * @param nat |
| 63 | * The Nature of the given Ability |
| 64 | */ |
| 65 | CNAbility(Category<Ability> cat, Ability abil, Nature nat) |
| 66 | { |
| 67 | Objects.requireNonNull(cat, "Cannot build CNAbility with null Category"); |
| 68 | Objects.requireNonNull(abil, "Cannot build CNAbility with null Ability"); |
| 69 | Objects.requireNonNull(nat, "Cannot build CNAbility with null Nature"); |
| 70 | if (abil.getKeyName() == null || abil.getKeyName().isEmpty()) |
| 71 | { |
| 72 | throw new IllegalArgumentException("Cannot build CNAbility when Ability has no key"); |
| 73 | } |
| 74 | Category<Ability> origCategory = abil.getCDOMCategory(); |
| 75 | if (origCategory == null) |
| 76 | { |
| 77 | throw new IllegalArgumentException( |
| 78 | "Cannot build CNAbility for " + abil + " when Ability has null original Category"); |
| 79 | } |
| 80 | if (!cat.getParentCategory().equals(origCategory)) |
| 81 | { |
| 82 | throw new IllegalArgumentException("Cannot build CNAbility for " + abil + " with incompatible Category: " |
| 83 | + cat + " is not compatible with Ability's Category: " + origCategory); |
| 84 | } |
| 85 | category = cat; |
| 86 | ability = abil; |
| 87 | nature = nat; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Returns the key for the Ability in this CNAbility. |
| 92 | * |
| 93 | * @return The key for the Ability in this CNAbility. |
| 94 | */ |
| 95 | public String getAbilityKey() |
| 96 | { |
| 97 | return ability.getKeyName(); |
| 98 | } |
nothing calls this directly
no outgoing calls
no test coverage detected