我的应用程序有一个问题,我不能实例化一个类
这是java.lang.ClassCastException
eclipse.emf.editeurgraphique.risque.features.StartEventFeature$CreateStartEventFeature cannot be cast to org.eclipse.graphiti.features.ICreateFeature
at eclipse.emf.editeurgraphique.risque.features.StartEventFeature.getCreateFeature(StartEventFeature.java:43)
这是我的方法:
public ICreateFeature getCreateFeature(IFeatureProvider fp) {
return (ICreateFeature) new CreateStartEventFeature(fp);
}
my Interface:
public interface ICreateFeature extends ICreate, IFeature {
}
和我的类
public CreateStartEventFeature(IFeatureProvider fp) {
super(fp, "Start Event", "Indicates the start of a process or choreography");
}
您的CreateStartEventFeature不会扩展您定义的任何类,因此通过调用超级构造函数
super(fp, "Start Event", "Indicates the start of a process or choreography");
CreateStartEventFeature需要实现接口:
public class CreateStartEventFeature extends MyBaseClass implements ICreateFeature
{...}
这个问题有点令人困惑,因为它没有显示整个问题,但我假设CreateStartEventFeature实现了ICreateFeature,所以尝试省略显式转换:
public ICreateFeature getCreateFeature(IFeatureProvider fp) {
return new CreateStartEventFeature(fp);
}