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

org.kuali.rice.kew.api.document.PropertyDefinition Maven / Gradle / Ivy

/**
 * Copyright 2005-2017 The Kuali Foundation
 *
 * Licensed under the Educational Community License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.opensource.org/licenses/ecl2.php
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kuali.rice.kew.api.document;

import java.util.Collection;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import org.apache.commons.lang.StringUtils;
import org.kuali.rice.core.api.CoreConstants;
import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
import org.w3c.dom.Element;

@XmlRootElement(name = PropertyDefinition.Constants.ROOT_ELEMENT_NAME)
@XmlAccessorType(XmlAccessType.NONE)
@XmlType(name = PropertyDefinition.Constants.TYPE_NAME, propOrder = {
        PropertyDefinition.Elements.NAME,
        PropertyDefinition.Elements.VALUE,
        CoreConstants.CommonElements.FUTURE_ELEMENTS
})
public final class PropertyDefinition extends AbstractDataTransferObject {

    @XmlElement(name = Elements.NAME, required = true)
    private final String name;

    @XmlElement(name = Elements.VALUE, required = false)
    private final String value;

    @SuppressWarnings("unused")
    @XmlAnyElement
    private final Collection _futureElements = null;

    @SuppressWarnings("unused")
    private PropertyDefinition() {
        this.name = null;
        this.value = null;
    }

    public static PropertyDefinition create(String name, String value) {
        return new PropertyDefinition(name, value);
    }

    private PropertyDefinition(String name, String value) {
        if (StringUtils.isBlank(name)) {
            throw new IllegalArgumentException("name is null or blank");
        }
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public String getValue() {
        return value;
    }

    /**
     * Defines some internal constants used on this class.
     */
    static class Constants {
        final static String ROOT_ELEMENT_NAME = "propertyDefinition";
        final static String TYPE_NAME = "PropertyDefinitionType";
    }

    /**
     * A private class which exposes constants which define the XML element names to use when this
     * object is marshalled to XML.
     */
    static class Elements {
        final static String NAME = "name";
        final static String VALUE = "value";
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy