小编Dam*_*ger的帖子

使用xmlelement defaultvalue注释指定默认值的简单方法

我通过JAXB有一个简单的pojo注释类:

    public class MyPojo
    implements Serializable
{

    private final static long serialVersionUID = 1234L;
    @XmlElement(name = "Type", required = true, defaultValue = "none")
    @NotNull
    protected SeismicDataAcquisitionSystemType type;
    @XmlElement(name = "IpAddress", required = true)
    @NotNull
    @Pattern(regexp = "((1?[0-9]?[0-9]|2[0-4]|[0-9]|25[0-5]).){3}(1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])")
    protected String ipAddress;
    @XmlElement(name = "SealServerTcpPort", defaultValue = "1477")
    @NotNull
    protected int sealServerTcpPort;
    @XmlElement(name = "PamServerTcpPort", defaultValue = "1485")
    @NotNull
    protected int pamServerTcpPort;

    /**
     * Obtient la valeur de la propriété type.
     * 
     * @return
     *     possible object is
     *     {@link SeismicDataAcquisitionSystemType } …
Run Code Online (Sandbox Code Playgroud)

java annotations jaxb

7
推荐指数
1
解决办法
1855
查看次数

标签 统计

annotations ×1

java ×1

jaxb ×1