001    /**
002     * Copyright 2005-2011 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     */
016    package org.kuali.rice.kew.api.action;
017    
018    import java.util.Collection;
019    
020    import javax.xml.bind.annotation.XmlAccessType;
021    import javax.xml.bind.annotation.XmlAccessorType;
022    import javax.xml.bind.annotation.XmlAnyElement;
023    import javax.xml.bind.annotation.XmlElement;
024    import javax.xml.bind.annotation.XmlRootElement;
025    import javax.xml.bind.annotation.XmlType;
026    
027    import org.apache.commons.lang.StringUtils;
028    import org.kuali.rice.core.api.CoreConstants;
029    import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
030    import org.w3c.dom.Element;
031    
032    @XmlRootElement(name = MovePoint.Constants.ROOT_ELEMENT_NAME)
033    @XmlAccessorType(XmlAccessType.NONE)
034    @XmlType(name = MovePoint.Constants.TYPE_NAME, propOrder = {
035                    MovePoint.Elements.START_NODE_NAME,
036                    MovePoint.Elements.STEPS_TO_MOVE,
037                    CoreConstants.CommonElements.FUTURE_ELEMENTS
038    })
039    public final class MovePoint extends AbstractDataTransferObject {
040        
041            @XmlElement(name = Elements.START_NODE_NAME, required = true)
042        private final String startNodeName;
043            
044            @XmlElement(name = Elements.STEPS_TO_MOVE, required = true)
045        private final int stepsToMove;
046        
047        @SuppressWarnings("unused")
048        @XmlAnyElement
049        private final Collection<Element> _futureElements = null;
050    
051        private MovePoint() {
052            this.startNodeName = null;
053            this.stepsToMove = 0;
054        }
055        
056        private MovePoint(String startNodeName, int stepsToMove) {
057            if (StringUtils.isBlank(startNodeName)) {
058                    throw new IllegalArgumentException("startNodeName was null or blank");
059            }
060            this.startNodeName = startNodeName;
061            this.stepsToMove = stepsToMove;
062        }
063        
064        public static MovePoint create(String startNodeName, int stepsToMove) {
065            return new MovePoint(startNodeName, stepsToMove);
066        }
067        
068        public String getStartNodeName() {
069            return startNodeName;
070        }
071    
072        public int getStepsToMove() {
073            return stepsToMove;
074        }
075        
076        /**
077         * Defines some internal constants used on this class.
078         */
079        static class Constants {
080            final static String ROOT_ELEMENT_NAME = "movePoint";
081            final static String TYPE_NAME = "MovePointType";
082        }
083        
084        /**
085         * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
086         */
087        static class Elements {
088            final static String START_NODE_NAME = "startNodeName";
089            final static String STEPS_TO_MOVE = "stepsToMove";
090        }
091    
092    }