Fix checkstyle warnings in yang-jmx-generator-plugin
[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> extendsFQNs = new ArrayList<>();
30
31     private final List<FullyQualifiedName> implementsFQNs = new ArrayList<>();
32
33     private final List<String> bodyElements = new ArrayList<>();
34
35     public void addToBody(String element) {
36         bodyElements.add(element + "\n");
37     }
38
39     public void addClassAnnotation(Annotation annotation) {
40         addClassAnnotation(annotation.toString());
41     }
42
43     public void addClassAnnotation(String annotation) {
44         classAnnotations.add(checkNotNull(annotation));
45     }
46
47     public void addExtendsFQN(FullyQualifiedName fqn) {
48         extendsFQNs.add(fqn);
49     }
50
51     public void addImplementsFQN(FullyQualifiedName fqn) {
52         implementsFQNs.add(fqn);
53     }
54
55     public Optional<String> getCopyright() {
56         return copyright;
57     }
58
59     public void setCopyright(Optional<String> copyright) {
60         this.copyright = checkNotNull(copyright);
61     }
62
63     public Optional<String> getHeader() {
64         return header;
65     }
66
67     public void setHeader(Optional<String> header) {
68         this.header = checkNotNull(header);
69     }
70
71
72     public Optional<String> getClassJavaDoc() {
73         return classJavaDoc;
74     }
75
76     public void setClassJavaDoc(Optional<String> classJavaDoc) {
77         this.classJavaDoc = checkNotNull(classJavaDoc);
78     }
79
80
81     public FullyQualifiedName getFqn() {
82         return fqn;
83     }
84
85     public void setFqn(FullyQualifiedName fqn) {
86         this.fqn = fqn;
87     }
88
89     public List<FullyQualifiedName> getExtendsFQNs() {
90         return extendsFQNs;
91     }
92
93
94     public List<FullyQualifiedName> getImplementsFQNs() {
95         return implementsFQNs;
96     }
97
98
99     public TypeName getTypeName() {
100         return typeName;
101     }
102
103     public void setTypeName(TypeName typeName) {
104         this.typeName = typeName;
105     }
106
107
108     public JavaFileInput build() {
109         checkNotNull(copyright);
110         checkNotNull(header);
111         checkNotNull(classJavaDoc);
112         checkNotNull(typeName);
113         checkNotNull(fqn);
114
115         return new JavaFileInput() {
116
117             @Override
118             public FullyQualifiedName getFQN() {
119                 return fqn;
120             }
121
122             @Override
123             public Optional<String> getCopyright() {
124                 return copyright;
125             }
126
127             @Override
128             public Optional<String> getHeader() {
129                 return header;
130             }
131
132             @Override
133             public Optional<String> getClassJavaDoc() {
134                 return classJavaDoc;
135             }
136
137             @Override
138             public TypeName getType() {
139                 return typeName;
140             }
141
142             @Override
143             public List<FullyQualifiedName> getExtends() {
144                 return Collections.unmodifiableList(extendsFQNs);
145             }
146
147             @Override
148             public List<FullyQualifiedName> getImplements() {
149                 return Collections.unmodifiableList(implementsFQNs);
150             }
151
152             @Override
153             public List<String> getClassAnnotations() {
154                 return Collections.unmodifiableList(classAnnotations);
155             }
156
157             @Override
158             public List<String> getBodyElements() {
159                 return Collections.unmodifiableList(bodyElements);
160             }
161         };
162     }
163 }