8

Just read the Java Bean spec 1.01 which includes the decapitalize() function which states:

Utility method to take a string and convert it to normal Java variable name capitalization. This normally means converting the first character from upper case to lower case, but in the (unusual) special case when there is more than one character and both the first and second characters are upper case, we leave it alone.

So if I want to write a getter for a Java Bean property named qValue, does that mean I should use getqValue() rather than getQValue()?

Jason S
  • 184,598
  • 164
  • 608
  • 970
  • interesting: I've been programming in Java for 6 years and I never ran into this exception to camelCase until now. – Jason S May 20 '15 at 22:30
  • Eclipse seems to think so, `getqValue`. – Sotirios Delimanolis May 20 '15 at 22:38
  • You're running in a similar problem to the one I answered in http://stackoverflow.com/questions/30205006/why-does-jackson-2-not-recognize-the-first-capital-letter-if-the-leading-camel-c/30207335#30207335 – jbarrueta May 20 '15 at 22:41
  • damn. I got to say this was a really stupid decision by java bean. – ZhongYu May 21 '15 at 00:33
  • well it actually makes sense. Otherwise java bean property names can't start with a capital letter + therefore can't handle acronyms like `URI`. – Jason S May 21 '15 at 01:00

0 Answers0