Interface UnloadTarget
- All Known Implementing Classes:
UnloadTarget.All,UnloadTarget.Ids,UnloadTarget.Matching,UnloadTarget.None
public sealed interface UnloadTarget
permits UnloadTarget.None, UnloadTarget.All, UnloadTarget.Ids, UnloadTarget.Matching
Declarative target for
SkillInjector's unload operation.
Sealed over exactly four variants: UnloadTarget.None, UnloadTarget.All,
UnloadTarget.Ids, UnloadTarget.Matching. Construct via the static factories
none(), all(), ids(String...),
matching(Predicate).
Project targets Java 17, so dispatch inside SkillInjector uses
an if-else instanceof chain — the lazy permits self-check in
UnloadTarget.PermitsCheck keeps every dispatch site honest.
Semantics: None keeps everything (no-op), All clears
every activated id (ephemeral), Ids drops a specific set,
Matching drops ids accepted by its predicate.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordClear every currently-activated skill (ephemeral semantics).static final recordDrop a concrete set of skill ids.static final recordDrop every skill id accepted byUnloadTarget.Matching.test().static final recordKeep every currently-activated skill.static final classLazy holder — validates permits once on first dispatch-through. -
Method Summary
Modifier and TypeMethodDescriptionstatic UnloadTarget.Allall()Apply this target to anactiveSkillslist and return the remaining list.static voidVerifies (via reflection) that the sealed permits clause covers exactly the four subtypes this module expects.static UnloadTarget.Idsstatic UnloadTarget.Matchingstatic UnloadTarget.Nonenone()
-
Method Details
-
none
- Returns:
- a "no-op" target.
-
all
- Returns:
- a "clear all" target.
-
ids
- Returns:
- a "drop these ids" target (nulls / duplicates removed).
-
matching
- Returns:
- a "drop ids matching predicate" target.
-
apply
-
assertPermitsCoverExpected
static void assertPermitsCoverExpected()Verifies (via reflection) that the sealed permits clause covers exactly the four subtypes this module expects. Runs once, lazily, via theUnloadTarget.PermitsCheckholder.Why reflection? Because the project targets Java 17, dispatch sites use manual
if-else instanceofchains — the compiler does NOT warn when a fifth permitted subtype is added and a chain is not extended. This one-time volatile-read guard costs effectively nothing.
-