JAXB生成的抽象类不是抽象的
我使用此模式通过 JAXB 生成 java 类。但是,生成的类不是抽象的。此外,当我包含实现类的绑定时,我无法声明该类抽象,因为对象工厂需要创建一个实例。我不完全理解这一点。有人可以帮忙吗?谢谢 !
<xs:complexType name="AbstractClass" abstract="true">
<xs:complexContent>
<xs:extension base="someModel:BaseClass">
<xs:sequence>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
I use this schema to generate a java class through JAXB. However, the generated class is not abstract. Also when I include a binding for an implementation class, I am unable to declare that class abstract since Object Factory needs to create an instance. I don't fully understand this. Could anybody help? Thanks !
<xs:complexType name="AbstractClass" abstract="true">
<xs:complexContent>
<xs:extension base="someModel:BaseClass">
<xs:sequence>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
IIRC 摘要只是说通常你不会实例化这个类,它应该仅用于扩展。所以抽象检查由JAXB决定,与语言级抽象类无关
IIRC abstract just says that normaly you won't instantiate this class and it should be used for extension only. So abstract check is up to JAXB and has nothing to do with language-level abstract classes
您应该看到为抽象复杂类型创建的抽象类(请参见下面的示例)。您能否提供有关 XML 架构的更多详细信息?
inheritance.xsd
contactInfo
是一个抽象的复杂类型。XJC 调用
ContactInfo
生成的
ConactInfo
类是抽象的:You should see an abstract class created for abstract complex types (see example below). Can you provide more details about your XML schema?
inheritance.xsd
contactInfo
is an abstract complex type.XJC Call
ContactInfo
The generated
ConactInfo
class is abstract: