Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.text.TextUtils;
import java.lang.reflect.Method;

public class Main {
    private static Object data;

    public static boolean has(int key) {
        Method method = getHasMethod(data.getClass());
        try {
            return (Boolean) method.invoke(data, key);
        } catch (Exception e) {
        }

        return false;
    }

    private static Method getHasMethod(Class clazz) {
        Method[] methods = clazz.getDeclaredMethods();
        for (Method method : methods) {
            if (TextUtils.equals(method.getName(), "has")) {
                return method;
            }
        }
        return null;
    }
}