RaceTypeToken is a Primitive that filters based on the RaceType of a Race.
| 34 | * RaceTypeToken is a Primitive that filters based on the RaceType of a Race. |
| 35 | */ |
| 36 | public class RaceTypeToken implements PrimitiveToken<Race>, PrimitiveFilter<Race> |
| 37 | { |
| 38 | private static final Class<Race> RACE_CLASS = Race.class; |
| 39 | private RaceType racetype; |
| 40 | private CDOMReference<Race> allRaces; |
| 41 | |
| 42 | @Override |
| 43 | public boolean initialize(LoadContext context, Class<Race> cl, String value, String args) |
| 44 | { |
| 45 | if (args != null) |
| 46 | { |
| 47 | return false; |
| 48 | } |
| 49 | racetype = RaceType.getConstant(value); |
| 50 | allRaces = context.getReferenceContext().getCDOMAllReference(RACE_CLASS); |
| 51 | return true; |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public String getTokenName() |
| 56 | { |
| 57 | return "RACETYPE"; |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public Class<Race> getReferenceClass() |
| 62 | { |
| 63 | return RACE_CLASS; |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public String getLSTformat(boolean useAny) |
| 68 | { |
| 69 | return getTokenName() + '=' + racetype.toString(); |
| 70 | } |
| 71 | |
| 72 | @Override |
| 73 | public boolean allow(PlayerCharacter pc, Race race) |
| 74 | { |
| 75 | return racetype.equals(race.get(ObjectKey.RACETYPE)); |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | public GroupingState getGroupingState() |
| 80 | { |
| 81 | return GroupingState.ANY; |
| 82 | } |
| 83 | |
| 84 | @Override |
| 85 | public boolean equals(Object obj) |
| 86 | { |
| 87 | if (obj == this) |
| 88 | { |
| 89 | return true; |
| 90 | } |
| 91 | if (obj instanceof RaceTypeToken other) |
| 92 | { |
| 93 | return racetype.equals(other.racetype); |
nothing calls this directly
no outgoing calls
no test coverage detected