Class PluralFormatter

java.lang.Object
com.pnfsoftware.jeb.util.format.PluralFormatter

public class PluralFormatter extends Object
A trivial text formatter that takes quantities into account to produce singular-form or plural-form tokens.
  • Constructor Details

    • PluralFormatter

      public PluralFormatter()
  • Method Details

    • count

      public static String count(Number cnt, String value, String valuePlural)
      Produce the singular or plural form of a token based on a provided count.
      Parameters:
      cnt - count
      value - singular token
      valuePlural - plural token (optional)
      Returns:
      the resulting string
    • countS

      public static String countS(Number cnt, String value)
      A specialized, best-effort, and approximate version of count that assumes that the plural form of a provided singular English token is created by appending '-s' (or a variant, such as '-es' ) to the singular token.
      Parameters:
      cnt - count
      value - singular token
      Returns:
      the resulting string