enhance the java doc of dubbo-common module. (#5578)

This commit is contained in:
withthewind 2020-02-09 13:14:57 +08:00 committed by GitHub
parent 74e2d6814a
commit cb7d9f5ca0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 0 deletions

View File

@ -19,8 +19,22 @@ package org.apache.dubbo.common.utils;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
/**
* Miscellaneous method utility methods.
* Mainly for internal use within the framework.
*
* @author LiZhenNet
* @since 2.7.2
*/
public class MethodUtils {
/**
* Return {@code true} if the provided method is a set method.
* Otherwise, return {@code false}.
*
* @param method the method to check
* @return whether the given method is setter method
*/
public static boolean isSetter(Method method) {
return method.getName().startsWith("set")
&& !"set".equals(method.getName())
@ -29,6 +43,13 @@ public class MethodUtils {
&& ClassUtils.isPrimitive(method.getParameterTypes()[0]);
}
/**
* Return {@code true} if the provided method is a get method.
* Otherwise, return {@code false}.
*
* @param method the method to check
* @return whether the given method is getter method
*/
public static boolean isGetter(Method method) {
String name = method.getName();
return (name.startsWith("get") || name.startsWith("is"))
@ -39,6 +60,13 @@ public class MethodUtils {
&& ClassUtils.isPrimitive(method.getReturnType());
}
/**
* Return {@code true} If this method is a meta method.
* Otherwise, return {@code false}.
*
* @param method the method to check
* @return whether the given method is meta method
*/
public static boolean isMetaMethod(Method method) {
String name = method.getName();
if (!(name.startsWith("get") || name.startsWith("is"))) {
@ -62,6 +90,14 @@ public class MethodUtils {
return true;
}
/**
* Check if the method is a deprecated method. The standard is whether the {@link java.lang.Deprecated} annotation is declared on the class.
* Return {@code true} if this annotation is present.
* Otherwise, return {@code false}.
*
* @param method the method to check
* @return whether the given method is deprecated method
*/
public static boolean isDeprecated(Method method) {
return method.getAnnotation(Deprecated.class) != null;
}