BUG-1276: fixed generated union constructor
[yangtools.git] / code-generator / binding-java-api-generator / src / test / resources / compilation / bug1276 / foo.yang
1  module foo {
2
3    namespace "test:yang:union";
4    prefix "foo";
5
6    revision 2014-07-15 {
7    }
8
9
10    typedef ip-address {
11      type union {
12        type ipv4-address;
13        type ipv6-address;
14      }
15    }
16
17    typedef ipv4-address {
18      type string {
19        pattern
20          '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
21        +  '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
22        + '(%[\p{N}\p{L}]+)?';
23      }
24    }
25
26    typedef ipv6-address {
27      type string {
28        pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
29              + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
30              + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
31              + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
32              + '(%[\p{N}\p{L}]+)?';
33        pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
34              + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
35              + '(%.+)?';
36      }
37    }
38
39    typedef domain-name {
40      type string {
41        pattern '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*'
42             +  '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)'
43             +  '|\.';
44        length "1..253";
45      }
46    }
47
48    typedef host {
49      type union {
50        type ip-address;
51        type domain-name;
52      }
53    }
54
55     typedef int-type {
56         type union {
57             type binary;
58             type int8;
59         }
60     }
61
62  }