Integrate JavaTypeName as Identifier
[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.JavaTypeName;
14 import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
17
18 public final class CodegenGeneratedTOBuilder extends AbstractGeneratedTOBuilder {
19
20     private Restrictions restrictions;
21     private GeneratedPropertyBuilder SUID;
22     private String reference;
23     private String description;
24     private String moduleName;
25     private SchemaPath schemaPath;
26
27     public CodegenGeneratedTOBuilder(final JavaTypeName identifier) {
28         super(identifier);
29     }
30
31     @Override
32     public void setRestrictions(final Restrictions restrictions) {
33         this.restrictions = restrictions;
34     }
35
36     @Override
37     public void setSUID(final GeneratedPropertyBuilder suid) {
38         this.SUID = suid;
39     }
40
41     @Override
42     public GeneratedTransferObject build() {
43         return new GTO(this);
44     }
45
46     @Override
47     public void setDescription(final String description) {
48         this.description = description;
49     }
50
51     @Override
52     public void setModuleName(final String moduleName) {
53         this.moduleName = moduleName;
54     }
55
56     @Override
57     public void setSchemaPath(final SchemaPath schemaPath) {
58         this.schemaPath = schemaPath;
59     }
60
61     @Override
62     public void setReference(final String reference) {
63         this.reference = reference;
64     }
65
66     @Override
67     AbstractEnumerationBuilder newEnumerationBuilder(final JavaTypeName identifier) {
68         return new CodegenEnumerationBuilder(identifier);
69     }
70
71     private static final class GTO extends AbstractGeneratedTransferObject {
72         private final Restrictions restrictions;
73         private final GeneratedProperty SUID;
74         private final String reference;
75         private final String description;
76         private final String moduleName;
77         private final SchemaPath schemaPath;
78
79         public GTO(final CodegenGeneratedTOBuilder builder) {
80             super(builder);
81             this.restrictions = builder.restrictions;
82             this.reference = builder.reference;
83             this.description = builder.description;
84             this.moduleName = builder.moduleName;
85             this.schemaPath = builder.schemaPath;
86
87             if (builder.SUID == null) {
88                 this.SUID = null;
89             } else {
90                 this.SUID = builder.SUID.toInstance(GTO.this);
91             }
92         }
93
94         @Override
95         public Restrictions getRestrictions() {
96             return this.restrictions;
97         }
98
99         @Override
100         public GeneratedProperty getSUID() {
101             return this.SUID;
102         }
103
104         @Override
105         public String getDescription() {
106             return this.description;
107         }
108
109         @Override
110         public String getReference() {
111             return this.reference;
112         }
113
114         @Override
115         public Iterable<QName> getSchemaPath() {
116             return this.schemaPath.getPathFromRoot();
117         }
118
119         @Override
120         public String getModuleName() {
121             return this.moduleName;
122         }
123     }
124 }