On Sat, 7 Dec 2019 at 17:28, Bryan Rickman <bryan.rick...@gmail.com> wrote:

> I was doing conversions for JSON properties which often do use different
> cases. My conversions were from camelCase to the other cases, not delimited
> words. If that isn't a good fit, I won't bother, but I don't mind adding it
> if others think it could be useful.
>
>
In which case it seems to me that a generic solution would be to provide
the inverse of toCamelCase.
i.e. split a camelCase string into words.

Conversion into the other forms is then trivial.

AFAICT the class does PascalCase already; this would be worth documenting
if so.


> On Sat, Dec 7, 2019, 12:20 PM sebb <seb...@gmail.com> wrote:
>
> > On Sat, 7 Dec 2019 at 17:05, Bryan Rickman <bryan.rick...@gmail.com>
> > wrote:
> >
> > > I recently used the text.CaseUtils for converting to camelCase and
> > > PascalCase. I also needed to convert to snake_case and kebab-case, and
> > > ended up writing my own code for that (I wasn't really a big fan of
> other
> > > utility options out there). Would it be well received if I submitted a
> PR
> > > for adding that support to CaseUtils? If so, any recommendations on
> what
> > to
> > > include or not include?
> > >
> >
> > Is there a need for kebab-case in Java?
> > The hyphen is not valid in Java identifiers; indeed many other languages
> > don't allow them either.
> >
> > I'm not sure that it's worth adding snake_case either.
> > AFAICT it's trivial:  string.replaceAll(" ", "_")
> > (similarly for kebab-case)
> >
> > Or is it really more complicated than that?
> >
> > Seems to me that the cost outweighs the benefits in these cases.
> >
>

Reply via email to