@Test @SmallTest public void fromBundle() { Bundle bundle = new Bundle(); bundle.putString(APP_STATE_KEY, KEY); bundle.putString(APP_STATE_MESSAGE, MESSAGE); bundle.putInt(APP_STATE_SEVERITY, SEVERITY); bundle.putString(APP_STATE_DATA, DATA); KeyedAppState keyedAppState = KeyedAppState.fromBundle(bundle); assertThat(keyedAppState.getKey()).isEqualTo(KEY); assertThat(keyedAppState.getMessage()).isEqualTo(MESSAGE); assertThat(keyedAppState.getSeverity()).isEqualTo(SEVERITY); assertThat(keyedAppState.getData()).isEqualTo(DATA); }
static KeyedAppState fromBundle(Bundle bundle) { if (!isValid(bundle)) { throw new IllegalArgumentException("Bundle is not valid"); } return KeyedAppState.builder() .setKey(bundle.getString(APP_STATE_KEY)) .setSeverity(bundle.getInt(APP_STATE_SEVERITY)) .setMessage(bundle.getString(APP_STATE_MESSAGE)) .setData(bundle.getString(APP_STATE_DATA)) .build(); }
KeyedAppState { static KeyedAppState fromBundle(Bundle bundle) { if (!isValid(bundle)) { throw new IllegalArgumentException("Bundle is not valid"); } return KeyedAppState.builder() .setKey(bundle.getString(APP_STATE_KEY)) .setSeverity(bundle.getInt(APP_STATE_SEVERITY)) .setMessage(bundle.getString(APP_STATE_MESSAGE)) .setData(bundle.getString(APP_STATE_DATA)) .build(); } }
KeyedAppState { static KeyedAppState fromBundle(Bundle bundle) { if (!isValid(bundle)) { throw new IllegalArgumentException("Bundle is not valid"); } return KeyedAppState.builder() .setKey(bundle.getString(APP_STATE_KEY)) .setSeverity(bundle.getInt(APP_STATE_SEVERITY)) .setMessage(bundle.getString(APP_STATE_MESSAGE)) .setData(bundle.getString(APP_STATE_DATA)) .build(); } KeyedAppState(); }
KeyedAppState { static KeyedAppState fromBundle(Bundle bundle) { if (!isValid(bundle)) { throw new IllegalArgumentException("Bundle is not valid"); } return KeyedAppState.builder() .setKey(bundle.getString(APP_STATE_KEY)) .setSeverity(bundle.getInt(APP_STATE_SEVERITY)) .setMessage(bundle.getString(APP_STATE_MESSAGE)) .setData(bundle.getString(APP_STATE_DATA)) .build(); } KeyedAppState(); @NonNull static KeyedAppStateBuilder builder(); @NonNull abstract String getKey(); @Severity abstract int getSeverity(); @Nullable abstract String getMessage(); @Nullable abstract String getData(); }
KeyedAppState { static KeyedAppState fromBundle(Bundle bundle) { if (!isValid(bundle)) { throw new IllegalArgumentException("Bundle is not valid"); } return KeyedAppState.builder() .setKey(bundle.getString(APP_STATE_KEY)) .setSeverity(bundle.getInt(APP_STATE_SEVERITY)) .setMessage(bundle.getString(APP_STATE_MESSAGE)) .setData(bundle.getString(APP_STATE_DATA)) .build(); } KeyedAppState(); @NonNull static KeyedAppStateBuilder builder(); @NonNull abstract String getKey(); @Severity abstract int getSeverity(); @Nullable abstract String getMessage(); @Nullable abstract String getData(); static final int SEVERITY_INFO; static final int SEVERITY_ERROR; static final int MAX_KEY_LENGTH; static final int MAX_MESSAGE_LENGTH; static final int MAX_DATA_LENGTH; }