如果方法与mutator的命名约定匹配,则返回true。
/* 来自 时 代 J a v a - nowjava.com*/ //package com.nowjava; import java.lang.reflect.Method; public class Main { /** Prefix for all mutator methods. */ private static final String MUTATOR_PREFIX = "set"; /** * Return true if method matches naming convention for mutator. * * @param method the method. * @return true if method matches naming convention for mutator. */ public static boolean isMutator(final Method method) { final String name = method.getName(); return name.startsWith(MUTATOR_PREFIX) && name.length() > 3 && Void.TYPE == method.getGeneri