package org.ccci.gto.android.common.util;

import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import java.lang.reflect.Array;

public class BundleUtils {
    @Nullable
    @SuppressWarnings({"unchecked", "SuspiciousSystemArraycopy"})
    public static <T extends Parcelable> T[] getParcelableArray(@NonNull final Bundle bundle,
                                                                @Nullable final String key,
                                                                @NonNull final Class<T> clazz) {
        final Parcelable[] raw = bundle.getParcelableArray(key);
        if (raw == null) {
            return null;
        }

        // copy all objects to typed array
        final T[] arr = (T[]) Array.newInstance(clazz, raw.length);
        System.arraycopy(raw, 0, arr, 0, raw.length);
        return arr;
    }
}

@@ -921,11 +921,997 @@
 r;%0A    %7D
+%0A%0A    public static void putEnum(@NonNull final Bundle bundle, @Nullable final String key,%0A                               @Nullable final Enum%3C?%3E value) %7B%0A        bundle.putString(key, value != null ? value.name() : null);%0A    %7D%0A%0A    @Nullable%0A    public static %3CT extends Enum%3CT%3E%3E T getEnum(@NonNull final Bundle bundle, @NonNull final Class%3CT%3E type,%0A                                                @Nullable final String key) %7B%0A        return getEnum(bundle, type, key, null);%0A    %7D%0A%0A    @Nullable%0A    public static %3CT extends Enum%3CT%3E%3E T getEnum(@NonNull final Bundle bundle, @NonNull final Class%3CT%3E type,%0A                                                @Nullable final String key, @Nullable final T defValue) %7B%0A        final String raw = bundle.getString(key);%0A        if (raw == null) %7B%0A            return defValue;%0A        %7D%0A%0A        try %7B%0A            return Enum.valueOf(type, raw);%0A        %7D catch (final IllegalArgumentException e) %7B%0A            return defValue;%0A        %7D%0A    %7D
 %0A%7D%0A

add putEnum and getEnum Bundle utils