Java examples for Reflection:Method Return
Return true if method matches naming convention for mutator.
//package com.java2s; import java.lang.reflect.Method; public class Main { /** Prefix for all mutator methods. */ private static final String MUTATOR_PREFIX = "set"; /**// w w w. j a v a 2s .c o m * 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.getGenericReturnType() && method.getParameterTypes().length == 1; } }