All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alipay.v3.util.schema.model.option.Option Maven / Gradle / Ivy

There is a newer version: 3.1.6.ALL
Show newest version
package com.alipay.v3.util.schema.model.option;

import com.alipay.v3.util.schema.exception.SchemaException;
import com.alipay.v3.util.schema.model.enums.SchemaErrorEnum;
import com.alipay.v3.util.schema.util.StringUtil;
import com.alipay.v3.util.schema.util.XmlUtils;
import org.dom4j.Element;

/**
 * @author hongbi.wang
 * @version $Id: Option.java, v 0.1 2021年03月01日 11:13 AM hongbi.wang Exp $
 */
public class Option {
    protected String displayName;
    protected String value;

    public Element toElement(String attributeId) throws SchemaException {
        Element option = XmlUtils.createRootElement("option");
        if (StringUtil.isEmpty(this.displayName)) {
            throw new SchemaException(SchemaErrorEnum.OPTION_NAME_ERROR, attributeId);
        }
        if (StringUtil.isEmpty(this.value)) {
            throw new SchemaException(SchemaErrorEnum.OPTION_VALUE_ERROR, attributeId);
        }
        option.addAttribute("displayName", this.displayName);
        option.addAttribute("value", this.value);

        return option;
    }

    /**
     * Getter method for property displayName.
     *
     * @return property value of displayName
     */
    public String getDisplayName() {
        return displayName;
    }

    /**
     * Setter method for property displayName.
     *
     * @param displayName value to be assigned to property displayName
     */
    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    /**
     * Getter method for property value.
     *
     * @return property value of value
     */
    public String getValue() {
        return value;
    }

    /**
     * Setter method for property value.
     *
     * @param value value to be assigned to property value
     */
    public void setValue(String value) {
        this.value = value;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy