Mercurial > hg > Members > sugi > MessagePack-java
comparison src/main/java/org/msgpack/template/builder/beans/MethodDescriptor.java @ 0:cb825acd883a
first commit
author | sugi |
---|---|
date | Sat, 18 Oct 2014 15:06:15 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:cb825acd883a |
---|---|
1 // MODIFIED FOR THE MSGPACK PROJECT | |
2 // Licensed to the Apache Software Foundation (ASF) under one or more | |
3 // contributor license agreements. See the NOTICE file distributed with | |
4 // this work for additional information regarding copyright ownership. | |
5 // The ASF licenses this file to You under the Apache License, Version 2.0 | |
6 // (the "License"); you may not use this file except in compliance with | |
7 // the License. You may obtain a copy of the License at | |
8 // | |
9 // http://www.apache.org/licenses/LICENSE-2.0 | |
10 // | |
11 // Unless required by applicable law or agreed to in writing, software | |
12 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
13 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
14 // License for the specific language governing permissions and limitations under | |
15 // the License. | |
16 // | |
17 | |
18 package org.msgpack.template.builder.beans; | |
19 | |
20 import java.lang.reflect.Method; | |
21 | |
22 /** | |
23 * Describes a bean's method. | |
24 */ | |
25 public class MethodDescriptor extends FeatureDescriptor { | |
26 | |
27 private Method method; | |
28 | |
29 private ParameterDescriptor[] parameterDescriptors; | |
30 | |
31 /** | |
32 * <p> | |
33 * Constructs an instance with the given {@link Method} and | |
34 * {@link ParameterDescriptor}s. The {@link #getName()} is set as the name | |
35 * of the <code>method</code> passed. | |
36 * </p> | |
37 * | |
38 * @param method | |
39 * The Method to set. | |
40 * @param parameterDescriptors | |
41 * An array of parameter descriptors. | |
42 */ | |
43 public MethodDescriptor(Method method, | |
44 ParameterDescriptor[] parameterDescriptors) { | |
45 super(); | |
46 | |
47 if (method == null) { | |
48 throw new NullPointerException(); | |
49 } | |
50 this.method = method; | |
51 this.parameterDescriptors = parameterDescriptors; | |
52 | |
53 setName(method.getName()); | |
54 } | |
55 | |
56 /** | |
57 * <p> | |
58 * Constructs an instance with the given {@link Method}. The | |
59 * {@link #getName()} is set as the name of the <code>method</code> | |
60 * passed. | |
61 * </p> | |
62 * | |
63 * @param method | |
64 * The Method to set. | |
65 */ | |
66 public MethodDescriptor(Method method) { | |
67 super(); | |
68 | |
69 if (method == null) { | |
70 throw new NullPointerException(); | |
71 } | |
72 this.method = method; | |
73 | |
74 setName(method.getName()); | |
75 } | |
76 | |
77 /** | |
78 * <p> | |
79 * Gets the method. | |
80 * </p> | |
81 * | |
82 * @return A {@link Method} instance. | |
83 */ | |
84 public Method getMethod() { | |
85 return method; | |
86 } | |
87 | |
88 /** | |
89 * <p> | |
90 * Gets the parameter descriptors. | |
91 * </p> | |
92 * | |
93 * @return An array of {@link ParameterDescriptor} instance or | |
94 * <code>null</code>. | |
95 */ | |
96 public ParameterDescriptor[] getParameterDescriptors() { | |
97 return parameterDescriptors; | |
98 } | |
99 | |
100 void merge(MethodDescriptor anotherMethod){ | |
101 super.merge(anotherMethod); | |
102 if(method == null){ | |
103 method = anotherMethod.method; | |
104 } | |
105 if(parameterDescriptors == null){ | |
106 parameterDescriptors = anotherMethod.parameterDescriptors; | |
107 } | |
108 } | |
109 } |