public static boolean valid(@NonNull Intent intent, String stringKey, Class<Builder> dataClass) {
    if (dataClass == null) {
        throw new IllegalArgumentException("dataClass must be set");
    }

    if (!intent.hasExtra(stringKey)) {
        Log.d(TAG, "valid() called with: intent = [" + intent + "], stringKey = [" + stringKey + "], dataClass = [" + dataClass + "]  failed");
        return false;
    }

    if (intent.getSerializableExtra(stringKey) == null) {
        Log.d(TAG, "valid() called with: intent = [" + intent + "], stringKey = [" + stringKey + "], dataClass = [" + dataClass + "]  failed");
        return false;
    }

    if (!(dataClass.isAssignableFrom(intent.getSerializableExtra(stringKey).getClass()))) {
        Log.d(TAG, "valid() called with: intent = [" + intent + "], stringKey = [" + stringKey + "], dataClass = [" + dataClass + "]  failed");
        return false;
    }

    return true;
}j

 

sorsare

By sorsare

Leave a Reply

Your email address will not be published. Required fields are marked *




Enter Captcha Here :