Improper capitalization in StringUtils.capitalizedAsConstant()

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Improper capitalization in StringUtils.capitalizedAsConstant()

Hugi Thordarson
Hi all,
I’m encountering what I believe can be called improper capitalization in Property name creation when doing class generation. The problem is that if the capitalization method encounters several uppercase characters in a row, it will treat them as a single substring with the following lowercase characters.

Example: I have an attribute called “uniqueIDFromSystem”. The Property generated is called UNIQUE_IDFROM_SYSTEM but should probably be called UNIQUE_ID_FROM_SYSTEM.

I’m guessing changing this behaviour is not acceptable since it will probably break older code? If so, is there any way for me to hook into the class generation mechanism to introduce my own “fixed” property name generating method, or could we add a second fixed method to StringUtils?

Cheers,
- hugi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Improper capitalization in StringUtils.capitalizedAsConstant()

Mike Kienenberger
There's no reason why another method couldn't be added.   StringUtils
was originally just a list of methods I found helpful.

StringUtils is a POJO (plain old java object) inserted into the
velocity context.   You can add other objects with your own custom
functions:

https://cayenne.apache.org/docs/3.0/cgen.html shows how it's
configured using ant (config nested parameter)



On Tue, Feb 14, 2017 at 6:30 AM, Hugi Thordarson <[hidden email]> wrote:
> Hi all,
> I’m encountering what I believe can be called improper capitalization in Property name creation when doing class generation. The problem is that if the capitalization method encounters several uppercase characters in a row, it will treat them as a single substring with the following lowercase characters.
>
> Example: I have an attribute called “uniqueIDFromSystem”. The Property generated is called UNIQUE_IDFROM_SYSTEM but should probably be called UNIQUE_ID_FROM_SYSTEM.
>
> I’m guessing changing this behaviour is not acceptable since it will probably break older code? If so, is there any way for me to hook into the class generation mechanism to introduce my own “fixed” property name generating method, or could we add a second fixed method to StringUtils?
>
> Cheers,
> - hugi
Loading...