1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.flow;
20
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.List;
24 import javax.el.MethodExpression;
25 import javax.el.ValueExpression;
26 import javax.faces.flow.MethodCallNode;
27 import javax.faces.flow.Parameter;
28
29
30
31
32
33
34 public class MethodCallNodeImpl extends MethodCallNode implements Freezable
35 {
36 private String _id;
37 private MethodExpression _methodExpression;
38 private ValueExpression _outcome;
39
40 private List<Parameter> _parameters;
41 private List<Parameter> _unmodifiableParameters;
42
43 private boolean _initialized;
44
45 public MethodCallNodeImpl(String methodCallNodeId)
46 {
47 this._id = methodCallNodeId;
48 _parameters = new ArrayList<Parameter>();
49 _unmodifiableParameters = Collections.unmodifiableList(_parameters);
50 }
51
52 @Override
53 public MethodExpression getMethodExpression()
54 {
55 return _methodExpression;
56 }
57
58 @Override
59 public ValueExpression getOutcome()
60 {
61 return _outcome;
62 }
63
64 @Override
65 public List<Parameter> getParameters()
66 {
67 return _unmodifiableParameters;
68 }
69
70 public void addParameter(Parameter parameter)
71 {
72 checkInitialized();
73 _parameters.add(parameter);
74 }
75
76 @Override
77 public String getId()
78 {
79 return _id;
80 }
81
82 public void freeze()
83 {
84 _initialized = true;
85
86 for (Parameter value : _parameters)
87 {
88 if (value instanceof Freezable)
89 {
90 ((Freezable)value).freeze();
91 }
92 }
93 }
94
95 private void checkInitialized() throws IllegalStateException
96 {
97 if (_initialized)
98 {
99 throw new IllegalStateException("Flow is inmutable once initialized");
100 }
101 }
102
103 public void setMethodExpression(MethodExpression methodExpression)
104 {
105 checkInitialized();
106 this._methodExpression = methodExpression;
107 }
108
109 public void setOutcome(ValueExpression outcome)
110 {
111 checkInitialized();
112 this._outcome = outcome;
113 }
114
115 public void setId(String id)
116 {
117 checkInitialized();
118 this._id = id;
119 }
120 }