Example:
- * String s = getReadMethodName("name"); // getName
+ * String methodName = getReadMethodName("name"); // The method name is "getName".
*
- * @param fieldName The name of the property
- * @return read method name
+ * @param fieldName The name of the property.
+ * @return read-method name.
*/
public static String getReadMethodName(String fieldName) {
- return GET_PREFIX + upperCaseFirst(fieldName);
+ return buildMethodName(GET_PREFIX, fieldName);
}
/**
- * Returns read method name.
+ * Returns read-method name.
* Example 1:
- * String s = getReadMethodName("name", false); // getName
+ * String methodName = getReadMethodName("name", false); // The method name is "getName".
*
* Example 2:
- * String s = getReadMethodName("success", true); // isSuccess
+ * String methodName = getReadMethodName("success", true); // The method name is "isSuccess".
*
- * @param fieldName The name of the property
- * @param primitiveBoolean Whether the field type is primitive boolean
- * @return read method name
+ * @param fieldName The name of the property.
+ * @param primitiveBoolean Whether the field type is primitive boolean.
+ * @return read-method name.
*/
public static String getReadMethodName(String fieldName, boolean primitiveBoolean) {
- return (primitiveBoolean ? IS_PREFIX : GET_PREFIX) + upperCaseFirst(fieldName);
+ return buildMethodName((primitiveBoolean ? IS_PREFIX : GET_PREFIX), fieldName);
}
/**
- * Returns read method name.
+ * Returns read-method name.
+ * Example:
+ * String methodName = getPrimitiveBooleanReadMethodName("success"); // The method name is "isSuccess".
+ *
+ * @param fieldName The name of the property.
+ * @return read-method name.
+ */
+ public static String getPrimitiveBooleanReadMethodName(String fieldName) {
+ return buildMethodName(IS_PREFIX, fieldName);
+ }
+
+ /**
+ * Returns read-method name.
* Example 1:
- * Field field = Foo.class.getField("name"); // field.getType() != boolean.class - * String s = getReadMethodName(field); // getName + **Field field = Foo.class.getDeclaredField("name"); // Assume that the field type is not boolean.
+ *String methodName = getReadMethodName(field); // The method name is "getName".
*
Example 2:
- * Field field = Foo.class.getField("success"); // field.getType() == boolean.class - * String s = getReadMethodName(field); // isSuccess + ** @param field {@link Field} - * @return read method name + * @return read-method name. */ public static String getReadMethodName(Field field) { return getReadMethodName(field.getName(), field.getType() == boolean.class); } /** - * Returns read method name. + * Returns read-method name. *Field field = Foo.class.getDeclaredField("success"); // Assume that the field type is boolean.
+ *String methodName = getReadMethodName(field); // The method name is "isSuccess".
*
Example 1:
- * Field field = Foo.class.getField("name");
- * String s = getReadMethodName(field, false); // getName
+ * Field field = Foo.class.getDeclaredField("name"); // Assume that the field type is not boolean./code>
+ * String methodName = getReadMethodName(field, false); // The method name is "getName".
*
* Example 2:
- * Field field = Foo.class.getField("success"); - * String s = getReadMethodName(field, true); // isSuccess + ** @param field {@link Field} - * @param primitiveBoolean Whether the field type is primitive boolean - * @return read method name + * @param primitiveBoolean Whether the field type is primitive boolean. + * @return read-method name. */ public static String getReadMethodName(Field field, boolean primitiveBoolean) { return getReadMethodName(field.getName(), primitiveBoolean); } /** - * Returns write method name. + * Returns write-method name. *Field field = Foo.class.getDeclaredField("success"); // Assume that the field type is boolean.
+ *String methodName = getReadMethodName(field, true); // The method name is "isSuccess".
*
Example:
- * String s = getWriteMethodName("name"); // setName
+ * String methodName = getWriteMethodName("name"); // The method name is "setName".
*
- * @param fieldName The name of the property
- * @return write method name
+ * @param fieldName The name of the property.
+ * @return write-method name.
*/
public static String getWriteMethodName(String fieldName) {
- return SET_PREFIX + upperCaseFirst(fieldName);
+ return buildMethodName(SET_PREFIX, fieldName);
}
/**
- * Returns write method name.
+ * Returns write-method name.
* Example:
- * Field field = Foo.class.getField("name"); - * String s = getWriteMethodName(field); // setName + ** @param field {@link Field} - * @return write method name + * @return write-method name. */ public static String getWriteMethodName(Field field) { - return SET_PREFIX + upperCaseFirst(field.getName()); + return buildMethodName(SET_PREFIX, field.getName()); } - /** - * Returns read method. + * Returns read-method. *Field field = Foo.class.getDeclaredField("name");
+ *String methodName = getWriteMethodName(field); // The method name is "setName".
*
Example:
- * Method m = getReadMethod(Foo.class, "name");
+ * Method method = getReadMethod(Foo.class, "name");
*
- * @param type The Class object for the target bean
- * @param fieldName The name of the property
- * @return read method
+ * @param type The Class object for the target bean.
+ * @param fieldName The name of the property.
+ * @return read-method
+ * @throws IntrospectionException if an exception occurs during introspection.
*/
public static Method getReadMethod(Class> type, String fieldName) throws IntrospectionException {
return getPropertyDescriptor(fieldName, type).getReadMethod();
}
/**
- * Returns read method.
+ * Returns read-method.
* Example:
- * Field field = Foo.class.getField("name"); - * Method m = getReadMethod(field); + * Field field = Foo.class.getDeclaredField("name"); + * Method method = getReadMethod(field); ** @param field {@link Field} - * @return read method + * @return read-method + * @throws IntrospectionException if an exception occurs during introspection. */ public static Method getReadMethod(Field field) throws IntrospectionException { return getReadMethod(field.getDeclaringClass(), field.getName()); } /** - * Returns write method. + * Returns write-method. *
Example:
- * String s = getWriteMethod(Foo.class, "name");
+ * String methodName = getWriteMethod(Foo.class, "name");
*
* @param type The Class object for the target bean
* @param fieldName The name of the property
- * @return write method
+ * @return write-method
+ * @throws IntrospectionException if an exception occurs during introspection.
*/
public static Method getWriteMethod(Class> type, String fieldName) throws IntrospectionException {
return getPropertyDescriptor(fieldName, type).getWriteMethod();
}
/**
- * Returns write method.
+ * Returns write-method.
* Example:
- * Field field = Foo.class.getField("name"); - * Method m = getWriteMethod(field); + ** @param field {@link Field} - * @return read method + * @return read-method + * @throws IntrospectionException if an exception occurs during introspection. */ public static Method getWriteMethod(Field field) throws IntrospectionException { return getWriteMethod(field.getDeclaringClass(), field.getName()); } - /** * Returns value of the field of the object. * @param o Target bean * @param fieldName The name of the property * @return value + * @throws IntrospectionException if an exception occurs during introspection. * @throws NoSuchMethodException if method is not found. * @throws IllegalAccessException if the method is not accessible. * @throws InvocationTargetException if the underlying method throws an exception. @@ -189,6 +205,7 @@ public static Object read(Object o, String fieldName) throws IntrospectionExcept * @param o Target bean * @param field {@link Field} * @return value + * @throws IntrospectionException if an exception occurs during introspection. * @throws NoSuchMethodException if method is not found. * @throws IllegalAccessException if the method is not accessible. * @throws InvocationTargetException if the underlying method throws an exception. @@ -225,6 +242,7 @@ public static Object read(Object o, Method method) throws IllegalAccessException * @param fieldName The name of the property * @param returnType The return type * @return value + * @throws IntrospectionException if an exception occurs during introspection. * @throws NoSuchMethodException if method is not found. * @throws IllegalAccessException if the method is not accessible. * @throws InvocationTargetException if the underlying method throws an exception. @@ -243,6 +261,7 @@ public staticField field = Foo.class.getDeclaredField("name");
+ *Method method = getWriteMethod(field);
*