Skip to content

Instantly share code, notes, and snippets.

@DmytroMitin
Created November 13, 2016 23:23
Show Gist options
  • Save DmytroMitin/b0ad5ffdbf48e2af65e62bc4c939997c to your computer and use it in GitHub Desktop.
Save DmytroMitin/b0ad5ffdbf48e2af65e62bc4c939997c to your computer and use it in GitHub Desktop.
import java.util.Collection;
import java.util.Iterator;
public class Main {
interface A {}
class B {
void add(A... a) {}
void add(Collection<A> c) {}
}
<T extends A> T getA() {
return null;
}
void test() {
B b = new B();
b.add(this.<C>getA());
}
class C implements A, Collection<A> {
@Override
public int size() {
return 0;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public boolean contains(Object o) {
return false;
}
@Override
public Iterator<A> iterator() {
return null;
}
@Override
public Object[] toArray() {
return new Object[0];
}
@Override
public <T> T[] toArray(T[] a) {
return null;
}
@Override
public boolean add(A a) {
return false;
}
@Override
public boolean remove(Object o) {
return false;
}
@Override
public boolean containsAll(Collection<?> c) {
return false;
}
@Override
public boolean addAll(Collection<? extends A> c) {
return false;
}
@Override
public boolean removeAll(Collection<?> c) {
return false;
}
@Override
public boolean retainAll(Collection<?> c) {
return false;
}
@Override
public void clear() {}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment