public static MixedMode fromString(String id) { if (id == null) { throw new IllegalArgumentException("Can't convert null String to MixedMode"); } for (MixedMode mode : MixedMode.values()) { if (TextUtils.equals(mode.mId, id.toLowerCase())) { return mode; } } throw new IllegalArgumentException("Could not convert String id to MixedMode"); }