TextWithMnemonic () { String text = getText(); if (Strings.isEmpty(text)) return TextWithMnemonic.EMPTY; TextWithMnemonic mnemonic = TextWithMnemonic.fromMnemonicText(text, false); if (mnemonic != null) return mnemonic; // assume that it is already set int index = getMnemonicIndex(); return 0 <= index && index < text.length() ? TextWithMnemonic.fromPlainTextWithIndex(text, index) : TextWithMnemonic.fromPlainText(text, (char)getMnemonicCode()); }