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