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 java.util.Optional;
13 import javax.lang.model.element.Modifier;
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;
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);
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);
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);
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;
50 this.parameters = parameters;
51 this.throwsExceptions = throwsExceptions;
53 this.annotations = annotations;
57 public List<Annotation> getAnnotations() {
62 public String getJavadoc() {
66 public void setJavadoc(String javadoc) {
67 this.javadoc = javadoc;
71 public Optional<Modifier> getVisibility() {
72 return Optional.of(Modifier.PUBLIC);
76 public String getReturnType() {
81 public String getName() {
86 public List<Field> getParameters() {
91 public List<String> getThrowsExceptions() {
92 return throwsExceptions;
96 public Optional<String> getBody() {
97 return Optional.of(body);
101 public List<Modifier> getModifiers() {
106 public String toString() {
107 return MethodSerializer.toString(this);