001/**
002 * Copyright 2005-2018 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.kew.api.action;
017
018import javax.xml.bind.annotation.XmlAccessType;
019import javax.xml.bind.annotation.XmlAccessorType;
020import javax.xml.bind.annotation.XmlElement;
021import javax.xml.bind.annotation.XmlRootElement;
022import javax.xml.bind.annotation.XmlType;
023
024import org.apache.commons.lang.StringUtils;
025
026@XmlRootElement(name = AdHocToGroup_v2_1_2.Constants.ROOT_ELEMENT_NAME)
027@XmlAccessorType(XmlAccessType.NONE)
028@XmlType(name = AdHocToGroup_v2_1_2.Constants.TYPE_NAME, propOrder = {
029                AdHocToGroup_v2_1_2.Elements.TARGET_GROUP_ID
030})
031public final class AdHocToGroup_v2_1_2 extends AdHocCommand {
032
033        private static final long serialVersionUID = 1543126020560887187L;
034
035        @XmlElement(name = Elements.TARGET_GROUP_ID, required = true)
036        private final String targetGroupId;
037
038        private AdHocToGroup_v2_1_2() {
039                this.targetGroupId = null;
040        }
041        
042        private AdHocToGroup_v2_1_2(Builder builder) {
043                super(builder);
044                this.targetGroupId = builder.getTargetGroupId();
045        }
046
047        public String getTargetGroupId() {
048                return targetGroupId;
049        }
050        
051        public static final class Builder extends AdHocCommand.Builder<AdHocToGroup_v2_1_2> {
052                
053                private static final long serialVersionUID = 3062630774766721773L;
054
055                private String targetGroupId;
056                
057                private Builder(ActionRequestType actionRequested, String nodeName, String targetGroupId) {
058                        super(actionRequested, nodeName);
059                        setTargetGroupId(targetGroupId);
060                }
061                
062                public static Builder create(ActionRequestType actionRequested, String nodeName, String targetGroupId) {
063                        return new Builder(actionRequested, nodeName, targetGroupId);
064                }
065                
066                public String getTargetGroupId() {
067                        return targetGroupId;
068                }
069                
070                public void setTargetGroupId(String targetGroupId) {
071                        if (StringUtils.isBlank(targetGroupId)) {
072                                throw new IllegalArgumentException("targetGroupId was null or blank");
073                        }
074                        this.targetGroupId = targetGroupId;
075                }
076                
077                @Override
078                public AdHocToGroup_v2_1_2 build() {
079                        return new AdHocToGroup_v2_1_2(this);
080                }
081
082        }
083        
084        /**
085     * Defines some internal constants used on this class.
086     */
087    static class Constants {
088        final static String ROOT_ELEMENT_NAME = "adHocToGroup";
089        final static String TYPE_NAME = "AdHocToGroupType";
090    }
091    
092    /**
093     * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
094     */
095    static class Elements {
096        final static String TARGET_GROUP_ID = "targetGroupId";
097    }
098
099        public static AdHocToGroup to(AdHocToGroup_v2_1_2 adHocToGroup) {
100                return AdHocToGroup.Builder.create(adHocToGroup.getActionRequested(), adHocToGroup.getNodeName(), adHocToGroup.getTargetGroupId()).build();
101        }
102}