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