Clean up GeneratedProperty use
[mdsal.git] / binding / mdsal-binding-generator-api / src / main / java / org / opendaylight / mdsal / binding / model / api / MethodSignature.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.mdsal.binding.model.api;
9
10 import java.util.List;
11 import org.eclipse.jdt.annotation.NonNull;
12
13 /**
14  * The Method Signature interface contains simplified meta model for java method
15  * definition. Each method MUST be defined by name, return type, parameters and
16  * access modifier. <br>
17  * Additionally method MAY contain associated annotations and comment. By
18  * contract if method does not contain any comments or annotation definitions
19  * the {@link #getComment()} SHOULD rather return empty string and
20  * {@link #getAnnotations()} SHOULD rather return empty list than
21  * <code>null</code> values. <br>
22  * The defining Type contains the reference to Generated Type that declares
23  * Method Signature.
24  */
25 public interface MethodSignature extends TypeMember {
26     /**
27      * Returns <code>true</code> if the method signature is defined as abstract. <br>
28      * By default in java all method declarations in interface are defined as abstract, but the user does not need
29      * necessarily to declare abstract keyword in front of each method. <br>
30      * The abstract methods are allowed in Class definitions but only when the class is declared as abstract.
31      *
32      * @return <code>true</code> if the method signature is defined as abstract.
33      */
34     boolean isAbstract();
35
36     /**
37      * Returns {@code true} if this method is a {@code interface default} method.
38      *
39      * @return <code>true</code> if the method signature is defined as default.
40      */
41     boolean isDefault();
42
43     /**
44      * Returns the List of parameters that method declare. If the method does not contain any parameters, the method
45      * will return empty List.
46      *
47      * @return the List of parameters that method declare.
48      */
49     List<Parameter> getParameters();
50
51     /**
52      * Return the mechanics associated with this method.
53      *
54      * @return Associated mechanics
55      */
56     @NonNull ValueMechanics getMechanics();
57
58     /**
59      * The Parameter interface is designed to hold the information of method
60      * Parameter(s). The parameter is defined by his Name which MUST be unique
61      * as java does not allow multiple parameters with same names for one method
62      * and Type that is associated with parameter.
63      */
64     interface Parameter {
65
66         /**
67          * Returns the parameter name.
68          *
69          * @return the parameter name.
70          */
71         String getName();
72
73         /**
74          * Returns Type that is bounded to parameter name.
75          *
76          * @return Type that is bounded to parameter name.
77          */
78         Type getType();
79     }
80
81     /**
82      * Method return type mechanics. This is a bit of an escape hatch for various behaviors which are supported by
83      * code generation.
84      */
85     enum ValueMechanics {
86         /**
87          * Usual mechanics, nothing special is going on.
88          */
89         NORMAL,
90         /**
91          * Mechanics signaling that the method should not be returning empty collections, but rather squash tham
92          * to null.
93          */
94         NULLIFY_EMPTY,
95         /**
96          * Mechanics signaling that the method cannot legally return null. This is primarily useful for getters, where
97          * the declaration should end up having {@link NonNull} annotation attached to return type. For setters this
98          * indicates the setter should never accept a null value.
99          */
100         NONNULL,
101     }
102 }