
Untitled
By: a guest on
May 10th, 2012 | syntax:
None | size: 0.68 KB | hits: 13 | expires: Never
Generic with Variable Type Arguments
public interface Foo<R, P...> {
public R bar(P...) {/*misc*/}
}
public class Foo<R, P> {
/*
* Not sure how you intend to provide any kind of implementation
* here since you don't know what R or P are.
*/
public R bar(P parameters) { ... }
}
public class SomeFoo extends Foo<SomeResult, Pair<Baz, Bar>> {
public SomeResult bar(Pair<Baz, Bar> parameters) { ... }
}
SomeFoo foo = ...
SomeResult result = foo.bar(Pair.of(baz, bar));
class TypedInstance<T>{
Class<T> type;
T instance;
}
public whatever(TypedInstance<? extends Object>... whatever){
...
doSomethingWith(whatever[0].type, whatever[0].instance);
...
}