/** * @param keyword for example "few" or "other" * @return the index of the plural form corresponding to the keyword * @throws IllegalArgumentException if the keyword is not a plural form */ public static final int indexFromString(CharSequence keyword) { StandardPlural p = orNullFromString(keyword); if (p != null) { return p.ordinal(); } else { throw new IllegalArgumentException(keyword.toString()); } }
/** * @param keyword for example "few" or "other" * @return the index of the plural form corresponding to the keyword, or OTHER_INDEX */ public static final int indexOrOtherIndexFromString(CharSequence keyword) { StandardPlural p = orNullFromString(keyword); return p != null ? p.ordinal() : OTHER.ordinal(); }
/** * @param keyword for example "few" or "other" * @return the index of the plural form corresponding to the keyword, or a negative value */ public static final int indexOrNegativeFromString(CharSequence keyword) { StandardPlural p = orNullFromString(keyword); return p != null ? p.ordinal() : -1; }