/** * Determine property (field) name from given getter/setter method. * * @param method method to be examined. * @return property (field) name. */ public static String getPropertyName(final Method method) { if (!isGetter(method) && !isSetter(method)) { throw new IllegalArgumentException(LocalizationMessages.METHOD_NOT_GETTER_NOR_SETTER()); } final String methodName = method.getName(); final int offset = methodName.startsWith("is") ? 2 : 3; final char[] chars = methodName.toCharArray(); chars[offset] = Character.toLowerCase(chars[offset]); return new String(chars, offset, chars.length - offset); }
/** * Determine property (field) name from given getter/setter method. * * @param method method to be examined. * @return property (field) name. */ public static String getPropertyName(final Method method) { if (!isGetter(method) && !isSetter(method)) { throw new IllegalArgumentException(LocalizationMessages.METHOD_NOT_GETTER_NOR_SETTER()); } final String methodName = method.getName(); final int offset = methodName.startsWith("is") ? 2 : 3; final char[] chars = methodName.toCharArray(); chars[offset] = Character.toLowerCase(chars[offset]); return new String(chars, offset, chars.length - offset); }
/** * Get accessor method mappings (field -> getter/setter) for given class. * * @param clazz entity class to obtain property methods for. * @param isGetter flag determining whether to look for getters or setters. * @return non-null map of field-accessor mappings. */ public static Map<String, Method> getPropertyMethods(final Class<?> clazz, final boolean isGetter) { final Map<String, Method> methods = new HashMap<>(); for (final Method method : AccessController.doPrivileged(ReflectionHelper.getDeclaredMethodsPA(clazz))) { if ((isGetter && ReflectionHelper.isGetter(method)) || (!isGetter && ReflectionHelper.isSetter(method))) { methods.put(ReflectionHelper.getPropertyName(method), method); } } final Class<?> parent = clazz.getSuperclass(); // We're interested in fields/accessors in superclasses but not those from i.e. Object/Enum. if (parent != null && !parent.getPackage().getName().startsWith("java.lang")) { methods.putAll(getPropertyMethods(parent, isGetter)); } return methods; }
/** * Determine property (field) name from given getter/setter method. * * @param method method to be examined. * @return property (field) name. */ public static String getPropertyName(final Method method) { if (!isGetter(method) && !isSetter(method)) { throw new IllegalArgumentException(LocalizationMessages.METHOD_NOT_GETTER_NOR_SETTER()); } final String methodName = method.getName(); final int offset = methodName.startsWith("is") ? 2 : 3; final char[] chars = methodName.toCharArray(); chars[offset] = Character.toLowerCase(chars[offset]); return new String(chars, offset, chars.length - offset); }
/** * Determine property (field) name from given getter/setter method. * * @param method method to be examined. * @return property (field) name. */ public static String getPropertyName(final Method method) { if (!isGetter(method) && !isSetter(method)) { throw new IllegalArgumentException(LocalizationMessages.METHOD_NOT_GETTER_NOR_SETTER()); } final String methodName = method.getName(); final int offset = methodName.startsWith("is") ? 2 : 3; final char[] chars = methodName.toCharArray(); chars[offset] = Character.toLowerCase(chars[offset]); return new String(chars, offset, chars.length - offset); }
/** * Determine property (field) name from given getter/setter method. * * @param method method to be examined. * @return property (field) name. */ public static String getPropertyName(final Method method) { if (!isGetter(method) && !isSetter(method)) { throw new IllegalArgumentException(LocalizationMessages.METHOD_NOT_GETTER_NOR_SETTER()); } final String methodName = method.getName(); final int offset = methodName.startsWith("is") ? 2 : 3; final char[] chars = methodName.toCharArray(); chars[offset] = Character.toLowerCase(chars[offset]); return new String(chars, offset, chars.length - offset); }
/** * Determine property (field) name from given getter/setter method. * * @param method method to be examined. * @return property (field) name. */ public static String getPropertyName(final Method method) { if (!isGetter(method) && !isSetter(method)) { throw new IllegalArgumentException(LocalizationMessages.METHOD_NOT_GETTER_NOR_SETTER()); } final String methodName = method.getName(); final int offset = methodName.startsWith("is") ? 2 : 3; final char[] chars = methodName.toCharArray(); chars[offset] = Character.toLowerCase(chars[offset]); return new String(chars, offset, chars.length - offset); }
/** * Determine property (field) name from given getter/setter method. * * @param method method to be examined. * @return property (field) name. */ public static String getPropertyName(final Method method) { if (!isGetter(method) && !isSetter(method)) { throw new IllegalArgumentException(LocalizationMessages.METHOD_NOT_GETTER_NOR_SETTER()); } final String methodName = method.getName(); final int offset = methodName.startsWith("is") ? 2 : 3; final char[] chars = methodName.toCharArray(); chars[offset] = Character.toLowerCase(chars[offset]); return new String(chars, offset, chars.length - offset); }
/** * Get accessor method mappings (field -> getter/setter) for given class. * * @param clazz entity class to obtain property methods for. * @param isGetter flag determining whether to look for getters or setters. * @return non-null map of field-accessor mappings. */ public static Map<String, Method> getPropertyMethods(final Class<?> clazz, final boolean isGetter) { final Map<String, Method> methods = new HashMap<>(); for (final Method method : AccessController.doPrivileged(ReflectionHelper.getDeclaredMethodsPA(clazz))) { if ((isGetter && ReflectionHelper.isGetter(method)) || (!isGetter && ReflectionHelper.isSetter(method))) { methods.put(ReflectionHelper.getPropertyName(method), method); } } final Class<?> parent = clazz.getSuperclass(); // We're interested in fields/accessors in superclasses but not those from i.e. Object/Enum. if (parent != null && !parent.getPackage().getName().startsWith("java.lang")) { methods.putAll(getPropertyMethods(parent, isGetter)); } return methods; }
/** * Get accessor method mappings (field -> getter/setter) for given class. * * @param clazz entity class to obtain property methods for. * @param isGetter flag determining whether to look for getters or setters. * @return non-null map of field-accessor mappings. */ public static Map<String, Method> getPropertyMethods(final Class<?> clazz, final boolean isGetter) { final Map<String, Method> methods = Maps.newHashMap(); for (final Method method : AccessController.doPrivileged(ReflectionHelper.getDeclaredMethodsPA(clazz))) { if ((isGetter && ReflectionHelper.isGetter(method)) || (!isGetter && ReflectionHelper.isSetter(method))) { methods.put(ReflectionHelper.getPropertyName(method), method); } } final Class<?> parent = clazz.getSuperclass(); // We're interested in fields/accessors in superclasses but not those from i.e. Object/Enum. if (parent != null && !parent.getPackage().getName().startsWith("java.lang")) { methods.putAll(getPropertyMethods(parent, isGetter)); } return methods; }
/** * Get accessor method mappings (field -> getter/setter) for given class. * * @param clazz entity class to obtain property methods for. * @param isGetter flag determining whether to look for getters or setters. * @return non-null map of field-accessor mappings. */ public static Map<String, Method> getPropertyMethods(final Class<?> clazz, final boolean isGetter) { final Map<String, Method> methods = Maps.newHashMap(); for (final Method method : AccessController.doPrivileged(ReflectionHelper.getDeclaredMethodsPA(clazz))) { if ((isGetter && ReflectionHelper.isGetter(method)) || (!isGetter && ReflectionHelper.isSetter(method))) { methods.put(ReflectionHelper.getPropertyName(method), method); } } final Class<?> parent = clazz.getSuperclass(); // We're interested in fields/accessors in superclasses but not those from i.e. Object/Enum. if (parent != null && !parent.getPackage().getName().startsWith("java.lang")) { methods.putAll(getPropertyMethods(parent, isGetter)); } return methods; }