Imagine the following code, written in C#:
public class Provider<T>
{
T GetValue(); // implementation skipped for brevity
}
//
public class Converter<T1, T2>
{
T2 Convert(T1 value);// implementation skipped for brevity
}
//
public class SomeClass // No Generics Here
{
public T2 DoSomething<T1, T2>()
{
T1 value = new Provider<T1>().GetValue();
T2 result = new Converter<T1, T2>().Convert(value);
return result;
}
}
// and the usage
...
SomeClass some = new SomeClass();
SomeOtherType result = some.DoSomething<SomeType, SomeOtherType>();
Is it possible to achieve the same with Java - I want to know how to call a method in Java by providing the type arguments in the method usage, like above. I've done this in .NET and I know Java supports type constraints and inference, I am just messing it up with the syntax.