Q:

Java Wildcard Capture with a Generic Interface

I have a generic interface that I can't seem to be able to wrap my head around making a wildcard capture helper for, and it's driving me nuts.
I have an interface:
public interface Foo<T extends Bar> {
  boolean isA(T t);
  T B();
}

and it's implementation is being instantiated as such:
private Foo<? extends Bar> foo = new FooImpl();

Those two cannot change, and obviously I cannot directly access FooImpl(). Let's say that with FooImpl(), the interface takes and returns FooBar, which extends Bar.
My compilation issues come up when using 'foo' in my code as such: 
if ( foo.isA(foo.B()) ){ //whatever }

Where foo.B() returns type FooBar.
I understand this is a wildcard capture error, and that a helper will be needed, but I have no idea how to set one up. There is no method in the class where 'foo' is instantiated, in which 'foo' is a parameter, which is how most helpers seem to be written. 'foo' is only used to get FooBar objects, and to test FooBar objects.
Any help is greatly appreciated, and I hope I was clear. Thanks!

A:

Well the simplest thing is of course to add a convenience method on the interface for this:
public interface Foo<T extends Bar> {
    boolean isA(T t);
    T B();

    default boolean bIsA() {
        return this.isA(this.B());
    }
}

Anyhow, a capturing method is just a generic method with a type parameter:
static <T extends Bar> boolean bIsA(Foo<T> foo) {
    return foo.isA(foo.B());
}

There is not a whole lot more to it than that. The point of a capturing helper is just to get a Foo<T> and do whatever we need.
And then:
if ( Somewhere.bIsA(foo) ) {...}

