Fix HiddenField ignoreSetter propery not working for one letter fields, issue #730

This commit is contained in:
Michal Kordas 2015-03-09 13:49:27 +01:00 committed by Roman Ivanov
parent ba5555995f
commit aef1f36b5a
3 changed files with 16 additions and 2 deletions

View File

@ -412,8 +412,8 @@ public class HiddenFieldCheck
// we should not capitalize the first character if the second
// one is a capital one, since according to JavBeans spec
// setXYzz() is a setter for XYzz property, not for xYzz one.
if (name != null && name.length() > 0
&& (name.length() > 1 && !Character.isUpperCase(name.charAt(1))))
if (name != null && (name.length() == 1
|| (name.length() > 1 && !Character.isUpperCase(name.charAt(1)))))
{
setterName = name.substring(0, 1).toUpperCase() + name.substring(1);
}

View File

@ -99,6 +99,7 @@ public class HiddenFieldCheckTest
"253:40: " + getCheckMessage(MSG_KEY, "prop"),
"267:29: " + getCheckMessage(MSG_KEY, "prop"),
"278:41: " + getCheckMessage(MSG_KEY, "prop2"),
"290:19: " + getCheckMessage(MSG_KEY, "i"),
};
verify(checkConfig, getPath("InputHiddenField.java"), expected);
}
@ -271,6 +272,7 @@ public class HiddenFieldCheckTest
"253:40: " + getCheckMessage(MSG_KEY, "prop"),
"267:29: " + getCheckMessage(MSG_KEY, "prop"),
"278:41: " + getCheckMessage(MSG_KEY, "prop2"),
"290:19: " + getCheckMessage(MSG_KEY, "i"),
};
verify(checkConfig, getPath("InputHiddenField.java"), expected);
}
@ -348,6 +350,7 @@ public class HiddenFieldCheckTest
"253:40: " + getCheckMessage(MSG_KEY, "prop"),
"267:29: " + getCheckMessage(MSG_KEY, "prop"),
"278:41: " + getCheckMessage(MSG_KEY, "prop2"),
"290:19: " + getCheckMessage(MSG_KEY, "i"),
};
verify(checkConfig, getPath("InputHiddenField.java"), expected);
}

View File

@ -281,3 +281,14 @@ enum PropertySetter4 {
return this;
}
}
/** Tests setter for one letter field (issue #730). */
class OneLetterField
{
int i;
void setI(int i)
{
this.i = i;
}
}