Java 对于我的类/子类情况,最好的方法是什么?
我有一个类,它有四个字段,其中两个字段由“type”假设 下面的代码显示了我当前正在做的事情Java 对于我的类/子类情况,最好的方法是什么?,java,xml,jaxb,Java,Xml,Jaxb,我有一个类,它有四个字段,其中两个字段由“type”假设 下面的代码显示了我当前正在做的事情 @XmlAccessorType(XmlAccessType.FIELD) public abstract class CodeHl7 { @XmlAttribute private String code; @XmlAttribute private String codeSystem; @XmlAttribute private String co
@XmlAccessorType(XmlAccessType.FIELD)
public abstract class CodeHl7 {
@XmlAttribute
private String code;
@XmlAttribute
private String codeSystem;
@XmlAttribute
private String codeSystemName;
@XmlAttribute
private String displayName;
public CodeHl7() {
}
public CodeHl7(String code, String codeSystem, String codeSystemName, String displayName) {
this.code = code;
this.codeSystem = codeSystem;
this.codeSystemName = codeSystemName;
this.displayName = displayName;
}
}
public class LoincCodeHl7 extends CodeHl7{
public LoincCodeHl7(String code, String displayName) {
super(code, "2.16.840.1.113883.6.1", "LOINC", displayName);
}
}
public class TranslationCode extends CodeHl7{
public TranslationCode(String code, String displayName) {
super(code, "2.16.840.1.113883.3.4424.11.1.32", "KLAS_DOK_P1", displayName);
}
}
我甚至不知道这是不是一个好方法,或者这不是什么更好的方法?一些静态方法生成的代码,而不是设置参数