I have a class
public abstract class AbstractE<T, E extends Enum<E> & Flags>
{
public interface Flags{} /*marker interface*/
//...
//other code
}
and an interface
public interface IXYZAdapter
{
public <E extends Enum<E> & Flags> Set<E> getFlags();
}
Where Flags is an interface defined in AbstractE itself.
M extends AbstractE thus:
public class M extends AbstractE<Long, M.EF> implements IXYZAdapter
{
public enum EF implements AbstractE.Flags{flag1, flag2}
@Override /*from IXYZAdapter*/
public Set<M.EF> getFlags()
{return EnumSet.allOf(EF.class);}
}
Now, from the main code, I try to get a handle on the interface IXYZAdapter and invoke the getFlags method
IXYZAdapter adapter = (IXYZAdapter)m; //where m is an instance of AbstractE
Set s = adapter.getFlags();
I get the following compile time error in the main program last line (Set s = adapter.getFlags();)
invalid inferred types for E; inferred type does not conform to declared bound(s)
inferred: AbstractE.Flags bound(s): java.lang.Enum<AbstractE.Flags>,AbstractE.Flags
What am I doing wrong? I am using Java 6
Edited to specify the error location
return new EnumSet.allOf(EF.class);supposed to mean/do?public abstract class AbstractE<T, E extends Enum<E> & Flags>gives me compiler error, it needs to bepublic abstract class AbstractE<T, E extends Enum<E> & AbstractE.Flags>. please use copy/paste when asking this type of intricate question :)