判断是否有Setter方法<br>
判定方法是是否存在只有一个参数的setXXX方法

@param clazz 待测试类
@return 是否为Bean对象
@since 4.2.2
772129
public static boolean hasSetter(Class<?> clazz) {
		if (ClassUtil.isNormalClass(clazz)) {
			final Method[] methods = clazz.getMethods();
			for (Method method : methods) {
				if (method.getParameterTypes().length == 1 && method.getName().startsWith("set")) {
					// 检测包含标准的setXXX方法即视为标准的JavaBean
					return true;
				}
			}
		}
		return false;
	}
69867
public static <A extends Annotation> A getAnnotation(final Class<?> clazz, Class<A> annoClazz) {
        if (clazz == null || annoClazz == null) {
            return null;
        }

        return clazz.getAnnotation(annoClazz);
    }
132837
public static Method[] getAllInstanceMethods(final Class<?> clazz) {
        if (clazz == null) {
            return null;
        }

        List<Method> methods = new ArrayList<Method>();
        for (Method method : clazz.getMethods()) {
            if (!Modifier.isStatic(method.getModifiers())
                    && Modifier.isPublic(method.getModifiers())) {
                methods.add(method);
            }
        }

        return methods.toArray(new Method[methods.size()]);
    }
368108
static Map<String, Method> getAllGetters(Class<?> clazz) {
        Map<String, Method> methods = new HashMap<String, Method>();
        while (!clazz.equals(Object.class)) {
            for (Method m : clazz.getDeclaredMethods()) {
                if (Modifier.isStatic(m.getModifiers())) {
                    continue;
                }
                String propertyName = getGetterName(m);
                if (shouldIgnore(m)) {
                    methods.put(propertyName, null);
                }
                if (propertyName!=null && !methods.containsKey(propertyName)) {
                    methods.put(propertyName, m);
                }
            }
            clazz = clazz.getSuperclass();
        }
        return methods;
    }
62198
public static List<Field> getAllFields(Class clazz) {
        List<Field> all = new ArrayList<Field>();
        for (Class<?> c = clazz; c != Object.class && c != null; c = c.getSuperclass()) {
            Field[] fields = c.getDeclaredFields(); // 所有方法，不包含父类
            for (Field field : fields) {
                int mod = field.getModifiers();
                // 过滤static 和 transient，支持final
                if (Modifier.isStatic(mod) || Modifier.isTransient(mod)) {
                    continue;
                }
                field.setAccessible(true); // 不管private还是protect都可以
                all.add(field);
            }
        }
        return all;
    }
112647
public <T> T toBean(Class<T> clazz) {
		return BeanUtil.mapToBean(this, clazz, false);
	}
860192
public SerializerConfig setClass(final Class<? extends Serializer> clazz) {
        String className = clazz == null ? null : clazz.getName();
        return setClassName(className);
    }
1067523
public static List<Field> listFields(Class<?> clazz) {
    	assert clazz != null;
        Class<?> entityClass = clazz;
        List<Field> list = new ArrayList<Field>();
        while (!Object.class.equals(entityClass) && entityClass != null) {
            list.addAll(Arrays.asList(entityClass.getDeclaredFields()));
            entityClass = entityClass.getSuperclass();
        }
        return list;
    }
990901
public static boolean isNotPojo(Class<?> clazz) throws NullPointerException {
        Assert.notNull(clazz, "clazz不能为null");
        return Boolean.class.isAssignableFrom(clazz) || Character.class.isAssignableFrom(clazz)
               || Number.class.isAssignableFrom(clazz) || Map.class.isAssignableFrom(clazz)
               || String.class.isAssignableFrom(clazz) || Collection.class.isAssignableFrom(clazz)
               || Enum.class.isAssignableFrom(clazz) || isGeneralType(clazz);
    }
268828
public <T> Clazz<T> FindClazz( Class<T> clazz )
	{
		if( clazzz == null )
			return null;

		for( Clazz<?> c : clazzz.values() )
			if( c.getReflectedClass() == clazz )
			{
				@SuppressWarnings( "unchecked" )
				Clazz<T> result = (Clazz<T>) c;
				return result;
			}

		return null;
	}
579039
public static List<Method> getAllMethods(List<Method> methods, Class<?> clazz)
  {
    for (Method method : clazz.getDeclaredMethods())
    {
      methods.add(method);
    }

    if (clazz.getSuperclass() != null)
    {
      methods = getAllMethods(methods, clazz.getSuperclass());
    }

    return methods;
  }
1308222
static Optional<Method> getGetterForSetter(final Method setter, final Class<?> clazz) {
        // Attempt to find "getFoo" and then "isFoo"; the parameter type is not
        // definitively indicative of get vs is because an Optional wrapped
        // boolean can be exposed as get instead of is. Finally, attempt no prefix
        // in cases where the setter is setIsFoo and getter is isFoo; this also
        // covers setFoo and foo.
        final String baseName = setter.getName().substring(SETTER_METHOD_PREFIX.length());
        try {
            final String getterName = GETTER_GET_METHOD_PREFIX + baseName;
            return Optional.of(clazz.getDeclaredMethod(getterName));
        } catch (final NoSuchMethodException e1) {
            try {
                final String getterName = GETTER_IS_METHOD_PREFIX + baseName;
                return Optional.of(clazz.getDeclaredMethod(getterName));
            } catch (final NoSuchMethodException e2) {
                try {
                    final String getterName = baseName.substring(0, 1).toLowerCase(Locale.getDefault()) + baseName.substring(1);
                    return Optional.of(clazz.getDeclaredMethod(getterName));
                } catch (final NoSuchMethodException e3) {
                    return Optional.empty();
                }
            }
        }
    }
1108226
@SuppressWarnings("unchecked")
    public <T> List<T> getList(Class<T> clazz) {
        return (List<T>) objects;
    }
858096
public static Method getPropertySetterMethod(Class clazz, String property, Class propertyClazz) {
        String methodName = "set" + property.substring(0, 1).toUpperCase() + property.substring(1);
        try {
            return clazz.getMethod(methodName, propertyClazz);
        } catch (NoSuchMethodException e) {
            throw new SofaRpcRuntimeException("No setter method for " + clazz.getName() + "#" + property, e);
        }
    }
66325
public Method getJavaMethod(Class<?> clazz, String methodName) {
        String className = clazz.getName();
        Method[] methods = allMethodCache.get(className);
        if (methods == null) {
            initJavaClassCache(clazz);// 分析一次clazz,这时会跟新allMethodCache
            methods = allMethodCache.get(className);
        }
        if (methods == null) {
            return null;
        }

        for (Method method : methods) {
            if (methodName.equals(method.getName())) {
                return method;
            }
        }
        return null;
    }
547541
public static Map<String, Method> getSetters(Class<?> clazz) {
		Map<String, Method> setters = new HashMap<String, Method>();
		Method[] methods = clazz.getMethods();
		for (Method method : methods) {
			String methodName = method.getName();
			if (method.getParameterTypes().length == 1
					&& methodName.startsWith("set") && methodName.length() > 3
					&& method.getReturnType() == Void.TYPE) {
				String propertyName = methodName.substring(3, 4).toLowerCase();
				if (methodName.length() > 4) {
					propertyName += methodName.substring(4);
				}
				setters.put(propertyName, method);
			}
		}
		return setters;
	}
1043856
public final boolean registerMBean(final Class<?> clazz) {
		if (this.mbs != null && clazz != null) {
			try {
				final String fqnName = clazz.getCanonicalName();
				final String domain = fqnName.substring(0, fqnName.lastIndexOf('.'));
				final String type = fqnName.substring(fqnName.lastIndexOf('.') + 1);

				final ObjectName objectName = new ObjectName(String.format(
						beanNameFormat, domain, type));
				if (!mbs.isRegistered(objectName)) {
					LaunchingMessageKind.IJMX0004.format(objectName);
					mbs.registerMBean(clazz.newInstance(), objectName);
					LaunchingMessageKind.IJMX0005.format(objectName);
				}
				this.beanNames.add(objectName);
			} catch (Exception e) {
				LaunchingMessageKind.EJMX0004.format(clazz.getCanonicalName(), e);
				return false;
			}
		} else {
			LaunchingMessageKind.EJMX0002.format();
			return false;
		}
		return true;
	}