001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.commons.scxml.model;
018
019 import java.util.LinkedHashSet;
020 import java.util.Set;
021
022 /**
023 * The class in this SCXML object model that corresponds to the
024 * <parallel> SCXML element, which is a wrapper element to
025 * encapsulate parallel state machines. For the <parallel> element
026 * to be useful, each of its <state> substates must itself be
027 * complex, that is, one with either <state> or <parallel>
028 * children.
029 *
030 */
031 public class Parallel extends TransitionTarget {
032
033 /**
034 * Serial version UID.
035 */
036 private static final long serialVersionUID = 2L;
037
038 /**
039 * The set of parallel state machines contained in this <parallel>.
040 */
041 private Set children;
042
043 /**
044 * Constructor.
045 */
046 public Parallel() {
047 this.children = new LinkedHashSet();
048 }
049
050 /**
051 * Get the set of parallel state machines contained in this Parallel.
052 *
053 * @return Returns the state.
054 *
055 * @deprecated Use getChildren() instead.
056 */
057 public final Set getStates() {
058 return children;
059 }
060
061 /**
062 * Add a State to the list of parallel state machines contained
063 * in this Parallel.
064 *
065 * @param state The state to add.
066 *
067 * @deprecated Use addChild(TransitionTarget) instead.
068 */
069 public final void addState(final State state) {
070 if (state != null) {
071 this.children.add(state);
072 state.setParent(this);
073 }
074 }
075
076 /**
077 * Get the set of child transition targets (may be empty).
078 *
079 * @return Set Returns the children.
080 *
081 * @since 0.7
082 */
083 public final Set getChildren() {
084 return children;
085 }
086
087 /**
088 * Add a child.
089 *
090 * @param tt A child transition target.
091 *
092 * @since 0.7
093 */
094 public final void addChild(final TransitionTarget tt) {
095 // TODO: State is a sufficient enough type for the parameter
096 this.children.add(tt);
097 tt.setParent(this);
098 }
099
100 }
101