0
我想根据superClassII
类型进行一些处理。所以,我定义:开关(未知变量类型)
ClassExpressionType superClassIIType = superClassII.getClassExpressionType();
如果(superClassIIType = “ObjectMincardinality” or
“ObjectExactCardinality”`所以,
I do the same treatment for superClassII
else
我们什么也不做
这里是我的源代码的一部分。 :
switch(superClassIIType){
case OBJECT_EXACT_CARDINALITY:
case OBJECT_MIN_CARDINALITY:
if ((((superClassIIType)superClassII).getProperty().equals(
((OWLObjectMinCardinality)superClass).getProperty()){
int superClassIICardinality =((superClassIIType)superClassII).getCardinality();
...
}
break;
default:
break;
}
但是,似乎superClassIIType
未被接受。我试图通过一个简单的if ...else
来做我所需要的,其中if和else块包含相同的处理(它可以工作,但我认为它是天真的)。
能否请你告诉我哪里出了问题,如果实现什么,我需要使用其他替代))
这更像是一个Java问题,它与OWL有什么关系。 'superClassIIType'是一个对象,而不是一个java类,你不能强制转换它。相关的接口是['OWLObjectExactCardinality'](http://owlcs.github.io/owlapi/apidocs_4/org/semanticweb/owlapi/model/OWLObjectExactCardinality.html)和['OWLObjectMinCardinality'](http://owlcs.github .IO/owlapi/apidocs_4 /组织/ semanticweb/owlapi /模型/ OWLObjectMinCardinality.html)。 – dhke
...但是你可能会在你的情况下逃离['OWLObjectCardinalityRestriction'](http://owlcs.github.io/owlapi/apidocs_4/org/semanticweb/owlapi/api_id/objectCardinalityRestriction.html),有所需的方法。 – dhke