You may write an utility method
public class Util
{
/** Always throws {@link RuntimeException} with the given message */
public static <T> T throwException(String msg)
{
throw new RuntimeException(msg);
}
}
And use it like this:
public static AppConfig getInstance()
{
return mConfig != null ? mConfig : Util.<AppConfig> throwException("error");
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…