Bug 1411-3: MDSAL Binding2 Generator Util
[mdsal.git] / binding2 / mdsal-binding2-generator-util / src / main / java / org / opendaylight / mdsal / binding2 / generator / util / generated / type / builder / GeneratedTypeBuilderImpl.java
1 /*
2  * Copyright (c) 2016 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
9 package org.opendaylight.mdsal.binding2.generator.util.generated.type.builder;
10
11 import com.google.common.annotations.Beta;
12 import com.google.common.base.Optional;
13 import java.util.List;
14 import org.opendaylight.mdsal.binding2.model.api.GeneratedType;
15 import org.opendaylight.mdsal.binding2.model.api.type.builder.GeneratedTypeBuilder;
16 import org.opendaylight.yangtools.yang.common.QName;
17
18 @Beta
19 public final class GeneratedTypeBuilderImpl extends AbstractGeneratedTypeBuilder<GeneratedTypeBuilder> implements
20         GeneratedTypeBuilder {
21
22     private String description;
23     private String reference;
24     private String moduleName;
25     private List<QName> schemaPath;
26
27     public GeneratedTypeBuilderImpl(final String packageName, final String name) {
28         super(packageName, name);
29         setAbstract(true);
30     }
31
32     @Override
33     public GeneratedType toInstance() {
34         return new GeneratedTypeImpl(this);
35     }
36
37     @Override
38     public void setDescription(String description) {
39         this.description = description;
40     }
41
42     @Override
43     public void setModuleName(String moduleName) {
44         this.moduleName = moduleName;
45     }
46
47     @Override
48     public void setSchemaPath(List<QName> schemaPath) {
49         this.schemaPath = schemaPath;
50     }
51
52     @Override
53     public void setReference(String reference) {
54         this.reference = reference;
55     }
56
57     @Override
58     public String toString() {
59         StringBuilder builder = new StringBuilder();
60         builder.append("GeneratedTransferObject [packageName=");
61         builder.append(getPackageName());
62         builder.append(", name=");
63         builder.append(getName());
64         builder.append(", comment=");
65         builder.append(getComment());
66         builder.append(", annotations=");
67         builder.append(getAnnotations());
68         builder.append(", implements=");
69         builder.append(getImplementsTypes());
70         builder.append(", enclosedTypes=");
71         builder.append(getEnclosedTypes());
72         builder.append(", constants=");
73         builder.append(getConstants());
74         builder.append(", enumerations=");
75         builder.append(getEnumerations());
76         builder.append(", properties=");
77         builder.append(", methods=");
78         builder.append(getMethodDefinitions());
79         builder.append("]");
80         return builder.toString();
81     }
82
83     @Override
84     protected GeneratedTypeBuilderImpl thisInstance() {
85         return this;
86     }
87
88     private static final class GeneratedTypeImpl extends AbstractGeneratedType {
89
90         private final String description;
91         private final String reference;
92         private final String moduleName;
93         private final List<QName> schemaPath;
94
95         public GeneratedTypeImpl(final GeneratedTypeBuilderImpl builder) {
96             super(builder);
97
98             this.description = builder.description;
99             this.reference = builder.reference;
100             this.moduleName = builder.moduleName;
101             this.schemaPath = builder.schemaPath;
102         }
103
104         @Override
105         public Optional<String> getDescription() {
106             return Optional.of(description);
107         }
108
109         @Override
110         public Optional<String> getReference() {
111             return Optional.of(reference);
112         }
113
114         @Override
115         public List<QName> getSchemaPath() {
116             return schemaPath;
117         }
118
119         @Override
120         public String getModuleName() {
121             return moduleName;
122         }
123     }
124 }