View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.scxml2.model;
18  
19  import java.io.Serializable;
20  
21  /**
22   * The class in this SCXML object model that corresponds to the
23   * <initial> SCXML pseudo state element.
24   *
25   */
26  public class Initial implements Serializable {
27  
28      /**
29       * Serial version UID.
30       */
31      private static final long serialVersionUID = 1L;
32  
33      /**
34       * The parent State of this initial
35       */
36      private State parent;
37  
38      /**
39       * A conditionless transition that is always enabled and will be taken
40       * as soon as the state is entered. The target of the transition must
41       * be a descendant of the parent state of initial.
42       */
43      private SimpleTransition transition;
44  
45      /**
46       * Indicator if this Initial was automatically generated and not loaded from the SCXML Document itself
47       */
48      private boolean generated;
49  
50      /**
51       * Constructor.
52       */
53      public Initial() {
54          super();
55      }
56  
57      /**
58       * Get the parent State.
59       *
60       * @return Returns the parent state
61       */
62      public final State getParent() {
63          return parent;
64      }
65  
66  
67      /**
68       * Set the parent TransitionTarget.
69       *
70       * @param parent The parent state to set
71       */
72      public final void setParent(final State parent) {
73          this.parent = parent;
74          if (transition != null) {
75              transition.setParent(parent);
76          }
77      }
78  
79      /**
80       * Get the initial transition.
81       *
82       * @return Returns the transition.
83       */
84      public final SimpleTransition getTransition() {
85          return transition;
86      }
87  
88      /**
89       * Set the initial transition.
90       *
91       * @param transition The transition to set.
92       */
93      public final void setTransition(final SimpleTransition transition) {
94          this.transition = transition;
95          this.transition.setParent(getParent());
96      }
97  
98      /**
99       * @return true if this Initial was automatically generated and not loaded from the SCXML Document itself
100      */
101     public final boolean isGenerated() {
102         return generated;
103     }
104 
105     /**
106      * Marks this Initial as automatically generated after loading the SCXML Document
107      */
108     public final void setGenerated() {
109         this.generated = true;
110     }
111 }
112