Let\'s say I have an abstract class
public abstract class Trainer{}
I have specific trainers like :
pub
Despite design analysis, I think the most your-situation (closest to your already created design) answer is:
DogTrainer.Trainables
is TrainingActions
HorseTrainer.Trainables
is TrainingActions
Generally, your Trainables
is already a TrainingActions
so you can just provide Set
, because you already have your animal information in T
:
abstract class Trainer {
Set> completed = new HashSet>();
public void add(TrainingActions t ) {
completed.add( t );
}
}
And you have exactly what you want.
Usage:
DogTrainer tr = new DogTrainer();
tr.add( DogTrainer.Trainables.BITE );
If you are sure you want to enforce an Enum for your interface:
public & TrainingActions> void add( E t ) {
completed.add( t );
}