I'd like to to something like the following in Java and don't really know what to search for:
public interface Subject<T> {
}
public interface EMailAddress extends Subject<String> {
}
public interface Validator<T extends Subject<V>> {
Set<InputErrors> validate(final V thing); // this does not compile
}
I basically would like the parameter type of Validator#validate be the same as the generic type of Subject.
I could write it like so:
public interface Validator<A,B extends Subject<A>> {
Set<InputErrors> validate(final A thing);
}
But this would require me to declare instances like this, which seems verbose
private Validator<String,EMailAddress> validator;