Remove yang-test
[controller.git] / opendaylight / config / yang-jmx-generator-plugin / src / main / java / org / opendaylight / controller / config / yangjmxgenerator / plugin / ftl / model / MethodDefinition.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.controller.config.yangjmxgenerator.plugin.ftl.model;
9
10 import java.util.Collections;
11 import java.util.List;
12 import java.util.Optional;
13 import javax.lang.model.element.Modifier;
14
15 public class MethodDefinition implements Method {
16     private final List<Modifier> modifiers;
17     private final String returnType;
18     private final String name;
19     private final List<Field> parameters;
20     private final List<String> throwsExceptions;
21     private final String body;
22     private String javadoc = null;
23     private final List<Annotation> annotations;
24
25     // TODO remove, Constructor is in separate class
26     public static MethodDefinition createConstructor(String name,
27             List<Field> parameters, String body) {
28         return new MethodDefinition("", name, parameters, body);
29
30     }
31
32     public MethodDefinition(String returnType, String name,
33             List<Field> parameters, String body) {
34         this(Collections.emptyList(), returnType, name, parameters,
35                 Collections.emptyList(), Collections.emptyList(), body);
36     }
37
38     public MethodDefinition(String returnType, String name,
39             List<Field> parameters, List<Annotation> annotations, String body) {
40         this(Collections.emptyList(), returnType, name, parameters,
41                 Collections.emptyList(), annotations, body);
42     }
43
44     public MethodDefinition(List<Modifier> modifiers, String returnType,
45             String name, List<Field> parameters, List<String> throwsExceptions,
46             List<Annotation> annotations, String body) {
47         this.modifiers = modifiers;
48         this.returnType = returnType;
49         this.name = name;
50         this.parameters = parameters;
51         this.throwsExceptions = throwsExceptions;
52         this.body = body;
53         this.annotations = annotations;
54     }
55
56     @Override
57     public List<Annotation> getAnnotations() {
58         return annotations;
59     }
60
61     @Override
62     public String getJavadoc() {
63         return javadoc;
64     }
65
66     public void setJavadoc(String javadoc) {
67         this.javadoc = javadoc;
68     }
69
70     @Override
71     public Optional<Modifier> getVisibility() {
72         return Optional.of(Modifier.PUBLIC);
73     }
74
75     @Override
76     public String getReturnType() {
77         return returnType;
78     }
79
80     @Override
81     public String getName() {
82         return name;
83     }
84
85     @Override
86     public List<Field> getParameters() {
87         return parameters;
88     }
89
90     @Override
91     public List<String> getThrowsExceptions() {
92         return throwsExceptions;
93     }
94
95     @Override
96     public Optional<String> getBody() {
97         return Optional.of(body);
98     }
99
100     @Override
101     public List<Modifier> getModifiers() {
102         return modifiers;
103     }
104
105     @Override
106     public String toString() {
107         return MethodSerializer.toString(this);
108     }
109 }