/* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model; import java.util.Collections; import java.util.List; import java.util.Optional; import javax.lang.model.element.Modifier; public class MethodDefinition implements Method { private final List modifiers; private final String returnType; private final String name; private final List parameters; private final List throwsExceptions; private final String body; private String javadoc = null; private final List annotations; // TODO remove, Constructor is in separate class public static MethodDefinition createConstructor(String name, List parameters, String body) { return new MethodDefinition("", name, parameters, body); } public MethodDefinition(String returnType, String name, List parameters, String body) { this(Collections.emptyList(), returnType, name, parameters, Collections.emptyList(), Collections.emptyList(), body); } public MethodDefinition(String returnType, String name, List parameters, List annotations, String body) { this(Collections.emptyList(), returnType, name, parameters, Collections.emptyList(), annotations, body); } public MethodDefinition(List modifiers, String returnType, String name, List parameters, List throwsExceptions, List annotations, String body) { this.modifiers = modifiers; this.returnType = returnType; this.name = name; this.parameters = parameters; this.throwsExceptions = throwsExceptions; this.body = body; this.annotations = annotations; } @Override public List getAnnotations() { return annotations; } @Override public String getJavadoc() { return javadoc; } public void setJavadoc(String javadoc) { this.javadoc = javadoc; } @Override public Optional getVisibility() { return Optional.of(Modifier.PUBLIC); } @Override public String getReturnType() { return returnType; } @Override public String getName() { return name; } @Override public List getParameters() { return parameters; } @Override public List getThrowsExceptions() { return throwsExceptions; } @Override public Optional getBody() { return Optional.of(body); } @Override public List getModifiers() { return modifiers; } @Override public String toString() { return MethodSerializer.toString(this); } }