Sunday 8 December 2019

java - Generic Enum param in abstract method

I'm trying to make an abstract Object Factory and I tryied a few things and none of them worked.



What I would like to have is something like this that could be overrided:



public abstract ObjectFactory {

public abstract Obj createObject (Type t) ;

}



that I could extends ObjectFactory and have:



public AntFactory extends ObjectFactory {

@Override
public Ant createObject(AntType t) { }
}



but everything I tryied did not override the createObject method. The only thing that worked for me was:



public abstract ObjectFactory {

public abstract Obj createObject (Type t) ;

}


Theres something that I'm not understanding about this concept or it doesn't work for enum.




Is there a way to keep the extends of enum only in the method and still override it?

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...