From cb7d9f5ca0249636ea6cef96660633329873e2b3 Mon Sep 17 00:00:00 2001 From: withthewind Date: Sun, 9 Feb 2020 13:14:57 +0800 Subject: [PATCH] enhance the java doc of dubbo-common module. (#5578) --- .../dubbo/common/utils/MethodUtils.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/MethodUtils.java b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/MethodUtils.java index de8f470231..26b05eff52 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/MethodUtils.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/MethodUtils.java @@ -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; }