summaryrefslogtreecommitdiff
path: root/java/common/StructFactory.tpl
blob: 533005d5611b00e8d77f6842223d550cf0f83038 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package $(pkg);

import org.apache.qpid.transport.Struct;

class StructFactory {

    public static Struct create(int type)
    {
        switch (type)
        {
${
from genutil import *

fragment = """        case $name.TYPE:
            return new $name();
"""

for c in composites:
  name = cname(c)
  if c.name == "struct":
    out(fragment)
}        default:
            throw new IllegalArgumentException("type: " + type);
        }
    }

    public static Struct createInstruction(int type)
    {
        switch (type)
        {
${
for c in composites:
  name = cname(c)
  if c.name in ("command", "control"):
    out(fragment)
}        default:
            throw new IllegalArgumentException("type: " + type);
        }
    }

}