I have the following classes:
class Field<T> {
private final Class<T> type;
public Field(Class<T> type) {
this.type = type;
}
}
class Pick<V> {
private final V value;
private final Class<V> type;
public Pick(V value, Class<V> type) {
this.value = value;
this.type = type;
}
}
and the class the question is related to:
class PickField<T> extends Field<Pick<T>> {
public PickField(Class<Pick<T>> type) {
super(type);
}
}
Now this seems to be accepted by the compiler. Unfortunately I do not know/understand how I could create a new instance of PickField
, e.g. for String
picks.
This does - of course - not work:
new PickField<String>(Pick.class)
This is not allowed (I think I understand why):
new PickField<String>(Pick<String>.class)
So how to do it? Or does the whole approach somehow "smell"?