2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model;
10 import java.util.Collections;
11 import java.util.List;
12 import javax.lang.model.element.Modifier;
14 public class MethodDefinition implements Method {
15 private static final String VISIBILITY_PUBLIC = Modifier.PUBLIC.toString();
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;
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);
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);
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);
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;
52 this.parameters = parameters;
53 this.throwsExceptions = throwsExceptions;
55 this.annotations = annotations;
59 public List<Annotation> getAnnotations() {
64 public String getJavadoc() {
68 public void setJavadoc(String javadoc) {
69 this.javadoc = javadoc;
73 public String getVisibility() {
74 return VISIBILITY_PUBLIC;
78 public String getReturnType() {
83 public String getName() {
88 public List<Field> getParameters() {
92 public List<String> getThrowsExceptions() {
93 return throwsExceptions;
96 public String getBody() {
101 public List<String> getModifiers() {
106 public String toString() {
107 return MethodSerializer.toString(this);