1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.myfaces.flow;
20
21 import javax.faces.flow.ViewNode;
22
23 /**
24 *
25 * @since 2.2
26 * @author Leonardo Uribe
27 */
28 public class ViewNodeImpl extends ViewNode implements Freezable
29 {
30 private String _vdlDocumentId;
31 private String _id;
32
33 private boolean _initialized;
34
35 public ViewNodeImpl(String id, String vdlDocumentId)
36 {
37 this._vdlDocumentId = vdlDocumentId;
38 this._id = id;
39 }
40
41 @Override
42 public String getVdlDocumentId()
43 {
44 return _vdlDocumentId;
45 }
46
47 @Override
48 public String getId()
49 {
50 return _id;
51 }
52
53 public void freeze()
54 {
55 _initialized = true;
56 }
57
58 private void checkInitialized() throws IllegalStateException
59 {
60 if (_initialized)
61 {
62 throw new IllegalStateException("Flow is inmutable once initialized");
63 }
64 }
65
66 public void setVdlDocumentId(String vdlDocumentId)
67 {
68 checkInitialized();
69 this._vdlDocumentId = vdlDocumentId;
70 }
71
72 public void setId(String id)
73 {
74 checkInitialized();
75 this._id = id;
76 }
77 }