2a0f45297a012a91678436f7c673b900f3baa10e
[mdsal.git] / binding / mdsal-binding-generator-util / src / main / java / org / opendaylight / mdsal / binding / model / util / generated / type / builder / CodegenGeneratedTOBuilder.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.mdsal.binding.model.util.generated.type.builder;
9
10 import org.opendaylight.mdsal.binding.model.api.GeneratedProperty;
11 import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject;
12 import org.opendaylight.mdsal.binding.model.api.Restrictions;
13 import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
16
17 public final class CodegenGeneratedTOBuilder extends AbstractGeneratedTOBuilder {
18
19     private Restrictions restrictions;
20     private GeneratedPropertyBuilder SUID;
21     private String reference;
22     private String description;
23     private String moduleName;
24     private SchemaPath schemaPath;
25
26     public CodegenGeneratedTOBuilder(final String packageName, final String name) {
27         super(packageName, name);
28     }
29
30     @Override
31     public void setRestrictions(final Restrictions restrictions) {
32         this.restrictions = restrictions;
33     }
34
35     @Override
36     public void setSUID(final GeneratedPropertyBuilder suid) {
37         this.SUID = suid;
38     }
39
40     @Override
41     public GeneratedTransferObject build() {
42         return new GTO(this);
43     }
44
45     @Override
46     public void setDescription(final String description) {
47         this.description = description;
48     }
49
50     @Override
51     public void setModuleName(final String moduleName) {
52         this.moduleName = moduleName;
53     }
54
55     @Override
56     public void setSchemaPath(final SchemaPath schemaPath) {
57         this.schemaPath = schemaPath;
58     }
59
60     @Override
61     public void setReference(final String reference) {
62         this.reference = reference;
63     }
64
65     @Override
66     AbstractEnumerationBuilder newEnumerationBuilder(final String packageName, final String name) {
67         return new CodegenEnumerationBuilder(packageName, name);
68     }
69
70     private static final class GTO extends AbstractGeneratedTransferObject {
71         private final Restrictions restrictions;
72         private final GeneratedProperty SUID;
73         private final String reference;
74         private final String description;
75         private final String moduleName;
76         private final SchemaPath schemaPath;
77
78         public GTO(final CodegenGeneratedTOBuilder builder) {
79             super(builder);
80             this.restrictions = builder.restrictions;
81             this.reference = builder.reference;
82             this.description = builder.description;
83             this.moduleName = builder.moduleName;
84             this.schemaPath = builder.schemaPath;
85
86             if (builder.SUID == null) {
87                 this.SUID = null;
88             } else {
89                 this.SUID = builder.SUID.toInstance(GTO.this);
90             }
91         }
92
93         @Override
94         public Restrictions getRestrictions() {
95             return this.restrictions;
96         }
97
98         @Override
99         public GeneratedProperty getSUID() {
100             return this.SUID;
101         }
102
103         @Override
104         public String getDescription() {
105             return this.description;
106         }
107
108         @Override
109         public String getReference() {
110             return this.reference;
111         }
112
113         @Override
114         public Iterable<QName> getSchemaPath() {
115             return this.schemaPath.getPathFromRoot();
116         }
117
118         @Override
119         public String getModuleName() {
120             return this.moduleName;
121         }
122     }
123 }