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