I have a given set of interfaces, and I have to implement them. The interfaces are the following:
package com.something.interfaces;
public interface A {
void foo();
Set<B> bar();
}
package com.something.interfaces;
public interface B {
void foobar();
}
And my implementations are the following:
package com.something.implementations;
public class A implements com.something.interfaces.A {
@Override
public void foo(){
//Something
}
@Override
public Set<com.something.interfaces.B> bar(){
Set<com.something.implementations.B> something = new HashSet<com.something.implementations.B>();
//...
return something;
}
}
package com.something.implementations;
public class B implements com.something.interfaces.B {
@override
public void foobar(){
//Something
}
}
The problem is in the method bar() of the implemented class. It gives me the error:
Type mismatch: cannot convert from java.util.Set<com.something.interfaces.B> to java.util.Set<com.something.implementations.B>
I am 100% sure that the signature are respected, I tried just leaving the auto generated stubs to check. Maybe there is something I am missing on the theory, but how can I implement the method if this does not work?
Thanks
EDIT As this question has been marked as a possible duplicate, I will explain the difference with it.
That was a generic question, I have a really specific problem here. The interfaces are not accessible by me, because I am writing code that will be submitted and autograded using original interfaces, I won't submit any modifications.
Knowing what that question pointed out does not help me understand how to escape from this situation, because given these interfaces, I need to return my implemented versions of them, and that question really gave me no clue on how to do that.
EDIT2
In the comments, it has been pointed out that my requirements are not clear. I'll try to clarify.
I can't change the interfaces, I need to be sure that this is a problem of interfaces and that there is not a workaround for this. If this is the case, I will try to reason with my professor.