Remove yang-test
[controller.git] / opendaylight / config / yang-jmx-generator-plugin / src / main / java / org / opendaylight / controller / config / yangjmxgenerator / plugin / java / JavaFileInputBuilder.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
9 package org.opendaylight.controller.config.yangjmxgenerator.plugin.java;
10
11 import static com.google.common.base.Preconditions.checkNotNull;
12
13 import com.google.common.base.Optional;
14 import java.util.ArrayList;
15 import java.util.Collections;
16 import java.util.List;
17 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Annotation;
18
19 public class JavaFileInputBuilder {
20
21     private Optional<String> copyright = Optional.absent(), header = Optional.absent(), classJavaDoc = Optional.absent();
22
23     private TypeName typeName = TypeName.classType;
24
25     private FullyQualifiedName fqn;
26
27     private final List<String> classAnnotations = new ArrayList<>();
28
29     private final List<FullyQualifiedName> importFQNs = new ArrayList<>();
30
31     private final List<FullyQualifiedName> extendsFQNs = new ArrayList<>();
32
33     private final List<FullyQualifiedName> implementsFQNs = new ArrayList<>();
34
35     private final List<String> bodyElements = new ArrayList<>();
36
37     public void addToBody(String element) {
38         bodyElements.add(element + "\n");
39     }
40
41     public void addClassAnnotation(Annotation annotation) {
42         addClassAnnotation(annotation.toString());
43     }
44
45     public void addClassAnnotation(String annotation) {
46         classAnnotations.add(checkNotNull(annotation));
47     }
48
49     public void addImportFQN(FullyQualifiedName fqn) {
50         importFQNs.add(fqn);
51     }
52
53     public void addExtendsFQN(FullyQualifiedName fqn) {
54         extendsFQNs.add(fqn);
55     }
56
57     public void addImplementsFQN(FullyQualifiedName fqn) {
58         implementsFQNs.add(fqn);
59     }
60
61     public Optional<String> getCopyright() {
62         return copyright;
63     }
64
65     public void setCopyright(Optional<String> copyright) {
66         this.copyright = checkNotNull(copyright);
67     }
68
69     public Optional<String> getHeader() {
70         return header;
71     }
72
73     public void setHeader(Optional<String> header) {
74         this.header = checkNotNull(header);
75     }
76
77
78     public Optional<String> getClassJavaDoc() {
79         return classJavaDoc;
80     }
81
82     public void setClassJavaDoc(Optional<String> classJavaDoc) {
83         this.classJavaDoc = checkNotNull(classJavaDoc);
84     }
85
86
87     public FullyQualifiedName getFqn() {
88         return fqn;
89     }
90
91     public void setFqn(FullyQualifiedName fqn) {
92         this.fqn = fqn;
93     }
94
95     public List<FullyQualifiedName> getExtendsFQNs() {
96         return extendsFQNs;
97     }
98
99
100     public List<FullyQualifiedName> getImplementsFQNs() {
101         return implementsFQNs;
102     }
103
104
105     public TypeName getTypeName() {
106         return typeName;
107     }
108
109     public void setTypeName(TypeName typeName) {
110         this.typeName = typeName;
111     }
112
113
114     public JavaFileInput build() {
115         checkNotNull(copyright);
116         checkNotNull(header);
117         checkNotNull(classJavaDoc);
118         checkNotNull(typeName);
119         checkNotNull(fqn);
120
121         return new JavaFileInput() {
122
123             @Override
124             public FullyQualifiedName getFQN() {
125                 return fqn;
126             }
127
128             @Override
129             public Optional<String> getCopyright() {
130                 return copyright;
131             }
132
133             @Override
134             public Optional<String> getHeader() {
135                 return header;
136             }
137
138             @Override
139             public List<FullyQualifiedName> getImports() {
140                 return Collections.unmodifiableList(importFQNs);
141             }
142
143             @Override
144             public Optional<String> getClassJavaDoc() {
145                 return classJavaDoc;
146             }
147
148             @Override
149             public TypeName getType() {
150                 return typeName;
151             }
152
153             @Override
154             public List<FullyQualifiedName> getExtends() {
155                 return Collections.unmodifiableList(extendsFQNs);
156             }
157
158             @Override
159             public List<FullyQualifiedName> getImplements() {
160                 return Collections.unmodifiableList(implementsFQNs);
161             }
162
163             @Override
164             public List<String> getClassAnnotations() {
165                 return Collections.unmodifiableList(classAnnotations);
166             }
167
168             @Override
169             public List<String> getBodyElements() {
170                 return Collections.unmodifiableList(bodyElements);
171             }
172
173         };
174     }
175 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.