is Field Parcelable - Android android.os

Android examples for android.os:Parcel

Description

is Field Parcelable

Demo Code


//package com.java2s;

import java.lang.reflect.Field;

import android.os.Parcelable;

public class Main {
    public static boolean isParcelable(Field field) {
        return isParcelable(getFeildClass(field));
    }//from   w w  w . j av  a  2  s  .  c o m

    public static boolean isParcelable(Class<?> clazz) {
        if (isAssignableFrom(clazz, Parcelable.class)) {
            return true;
        }
        return false;
    }

    public static Class<?> getFeildClass(Field field) {
        return field.getType();
    }

    public static boolean isAssignableFrom(Class<?> clazz,
            Class<?> targetClazz) {
        if (targetClazz.isAssignableFrom(clazz)) {
            return true;
        }
        return false;
    }

    public static boolean isAssignableFrom(Field field, Class<?> targetClazz) {
        return isAssignableFrom(getFeildClass(field), targetClazz);
    }
}

Related Tutorials