Handles the logic of throwing an exception if the throwIfNotPresent is true and the bundle does not contain the key. - Android Android OS

Android examples for Android OS:Bundle Key

Description

Handles the logic of throwing an exception if the throwIfNotPresent is true and the bundle does not contain the key.

Demo Code


//package com.book2s;
import android.os.Bundle;

public class Main {
    /**// w  ww . j  a  v  a  2  s.  co  m
     * Handles the logic of throwing an exception if the throwIfNotPresent is
     * true and the bundle does not contain the key.
     * @param bundle
     * @param key
     * @param throwIfNotPresent
     * @return
     */
    protected static void doThrowHelper(Bundle bundle, String key,
            boolean throwIfNotPresent) {
        if (throwIfNotPresent && !bundle.containsKey(key)) {
            throw new IllegalArgumentException("bundle does not contain: "
                    + key);
        }
    }
}

Related Tutorials