Integrate JavaTypeName as Identifier
[mdsal.git] / binding / mdsal-binding-generator-util / src / main / java / org / opendaylight / mdsal / binding / model / util / generated / type / builder / RuntimeGeneratedTypeBuilder.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.GeneratedType;
11 import org.opendaylight.mdsal.binding.model.api.TypeComment;
12 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
13 import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
16
17 public final class RuntimeGeneratedTypeBuilder extends AbstractGeneratedTypeBuilder<GeneratedTypeBuilder> implements
18         GeneratedTypeBuilder {
19
20     public RuntimeGeneratedTypeBuilder(final JavaTypeName identifier) {
21         super(identifier);
22         setAbstract(true);
23     }
24
25     @Override
26     public GeneratedType build() {
27         return new GeneratedTypeImpl(this);
28     }
29
30     @Override
31     public void setDescription(final String description) {
32         // No-op
33     }
34
35     @Override
36     public void setModuleName(final String moduleName) {
37         // No-op
38     }
39
40     @Override
41     public void setSchemaPath(final SchemaPath schemaPath) {
42         // No-op
43     }
44
45     @Override
46     public void setReference(final String reference) {
47         // No-op
48     }
49
50     @Override
51     AbstractEnumerationBuilder newEnumerationBuilder(final JavaTypeName identifier) {
52         return new RuntimeEnumerationBuilder(identifier);
53     }
54
55     @Override
56     public String toString() {
57         final StringBuilder builder = new StringBuilder();
58         builder.append("GeneratedTransferObject [packageName=");
59         builder.append(getPackageName());
60         builder.append(", name=");
61         builder.append(getName());
62
63         final TypeComment comment = getComment();
64         if (comment != null) {
65             builder.append(", comment=");
66             builder.append(comment.getJavadoc());
67         }
68         builder.append(", annotations=");
69         builder.append(getAnnotations());
70         builder.append(", implements=");
71         builder.append(getImplementsTypes());
72         builder.append(", enclosedTypes=");
73         builder.append(getEnclosedTypes());
74         builder.append(", constants=");
75         builder.append(getConstants());
76         builder.append(", enumerations=");
77         builder.append(getEnumerations());
78         builder.append(", properties=");
79         builder.append(", methods=");
80         builder.append(getMethodDefinitions());
81         builder.append("]");
82         return builder.toString();
83     }
84
85     @Override
86     protected RuntimeGeneratedTypeBuilder thisInstance() {
87         return this;
88     }
89
90     private static final class GeneratedTypeImpl extends AbstractGeneratedType {
91         GeneratedTypeImpl(final RuntimeGeneratedTypeBuilder builder) {
92             super(builder);
93         }
94
95         @Override
96         public String getDescription() {
97             throw new UnsupportedOperationException("Not available at runtime");
98         }
99
100         @Override
101         public String getReference() {
102             throw new UnsupportedOperationException("Not available at runtime");
103         }
104
105         @Override
106         public Iterable<QName> getSchemaPath() {
107             throw new UnsupportedOperationException("Not available at runtime");
108         }
109
110         @Override
111         public String getModuleName() {
112             throw new UnsupportedOperationException("Not available at runtime");
113         }
114     }
115 }