Code example for List

Methods: get, isEmpty, size

0
    /** 
     * Verify that network states are valid 
     * @return false if any of the states are invalid 
     */ 
    private boolean validateNetworkStates() { 
        if (mStateDepository.isEmpty()) {
            Log.v(LOG_TAG, "no state is recorded");
            mReason = "no state is recorded.";
            return false; 
        } else if (mStateDepository.size() > 1) {
            Log.v(LOG_TAG, "no broadcast is expected, instead broadcast is probably received");
            mReason = "no broadcast is expected, instead broadcast is probably received";
            return false; 
        } else if (mStateDepository.get(0) != mTransitionTarget) {
            Log.v(LOG_TAG, String.format("%s is expected, but it is %s",
                    mTransitionTarget.toString(),
                    mStateDepository.get(0).toString()));
            mReason = String.format("%s is expected, but it is %s",
                    mTransitionTarget.toString(),
                    mStateDepository.get(0).toString());
            return false; 
        } 
        return true; 
    }