this is my code, Control is an swt-ui-widget, the method find should return a component with the type passed in “clazz”. I know how to do this with static methods, but it doesn’t work if it’s an instance method.
package org.uilib.swt.templating;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Control;
public class Component<T extends Control> {
public final String name;
public final T control;
public Component(String name, T control) {
this.name = name;
this.control = control;
}
public String getName() {
return name;
}
public T getControl() {
return control;
}
public Component<E> find(String query, Class<E extends Control> clazz) {
return null;
}
}
i want to do the following:
Component<Button> x = this.find("asd", Button.class);
As far as I understand, you need the following generic method: