in ruby on rails,this is plural and singular functions added to ruby String class.
how can i implements plural and singular functions in java?
such as "book" plural() => "books" "books" singular => "book"
in ruby on rails,this is plural and singular functions added to ruby String class.
how can i implements plural and singular functions in java?
such as "book" plural() => "books" "books" singular => "book"
Assuming you want to cover the exception cases too (e.g. person => people) then the module that handles this in Ruby on Rails is called Inflector
. Take a look at this Inflector project on java.net for something similar in Java. From the project summary:
Inflector is a Java API for forming plurals of words. The library supports English spellings, and is locale-aware so it is straightforward to customize for any language.
Note: that I think this might only do singular => plural and not the other way around.