I have a following line of code:
silk.<DomButton>find(buttonSubmitSearchXPathMain).select();
I've never seen a method being accompanied by <xxx>
. I have a few other methods like that with the same brackets but different words. Unfortunately I'm unable to read the source for this method. Can someone please explain what is it? Just a description of a method? What is a purpose of it? Where can I read about it?
It's a call to a static generic method. Have a look at this article. Generics allow generic programming.
For example this is a generic class:
public class GenericClass<T>{}
where generic type T is determined at compile time while instantiating the class.
GenericClass<String> class = new GenericClass<String>();
You can force the generic type to be descendant of a particular type. Example:
public class GenericClass<T extends JComponent>{}
This is useful to allow generic programming because inside a method you can threat the generic type independently of which is its real type.For example:
public class GenericClass<T extends JComponent>{
private T component;
public void showComponent(){
T.setVisible(true); //you can call this method. T could be a JComponent or a subclass of it
}
}
In your case you are specifying the generic type while calling the static method, because of its static nature it could be invoked without having an instance.