opermission/src/main/java/co/omkar/utility/opermission/RequestPermission.java
private static void invokeAnnotatedMethods(HashMap<Permission, Result> resultMap)
            throws InvocationTargetException, IllegalAccessException {
        Method[] methods = getBase().getClass().getDeclaredMethods();

        // check all methods from provided class or by default provided activity.
        for (Method method : methods) {

            if (method != null && method.isAnnotationPresent(GrantedPermission.class)) {
                GrantedPermission granted = method.getAnnotation(GrantedPermission.class);

                if (granted != null) {

                    /* Check single value annotations */
                    if (!granted.permission().equals("") || granted.value() != Permission.NONE) {
                        for (Map.Entry<Permission, Result> permResult : resultMap.entrySet()) {

                            // invoke method if String permission is annotated.
                            if ((granted.permission().equals(permResult.getKey().toString()) ||
                                    granted.value() == permResult.getKey())
                                    && Result.GRANTED == permResult.getValue()) {
                                method.invoke(getBase());
                                mLog.i(TAG, "invoking grant method: " + method.getName());
                            }
                        }
                        continue;
                    }

                    /* Check array fields in annotations */
                    if (granted.values().length > 0) {
                        if (allValuesGranted(granted.values(), resultMap)) {
                            method.invoke(getBase());
                            mLog.i(TAG, "invoking grant method: " + method.getName());
                        }
                        continue;
                    }

                    if (granted.permissions().length > 0) {
                        if (allValuesGranted(granted.permissions(), resultMap)) {
                            method.invoke(getBase());
                            mLog.i(TAG, "invoking grant method: " + method.getName());
                        }
                    }
                }
            } else if (method != null && method.isAnnotationPresent(DeniedPermission.class)) {
                DeniedPermission denied = method.getAnnotation(DeniedPermission.class);

                if (denied != null) {

                    /* Check single value annotations */
                    if (!denied.permission().equals("") || denied.value() != Permission.NONE) {
                        for (Map.Entry<Permission, Result> permResult : resultMap.entrySet()) {

                            // invoke method if String permission is annotated.
                            if ((denied.permission().equals(permResult.getKey().toString())
                                    || denied.value() == permResult.getKey())
                                    && Result.DENIED == permResult.getValue()) {
                                method.invoke(getBase());
                                mLog.i(TAG, "invoking denied method: " + method.getName());
                            }
                        }
                        continue;
                    }

                    /* Check array fields in annotations */
                    if (denied.values().length > 0) {
                        if (anyValueDenied(denied.values(), resultMap)) {
                            method.invoke(getBase());
                            mLog.i(TAG, "invoking denied method: " + method.getName());
                        }
                        continue;
                    }

                    if (denied.permissions().length > 0) {
                        if (anyValueDenied(denied.permissions(), resultMap)) {
                            mLog.i(TAG, "invoking denied method: " + method.getName());
                            method.invoke(getBase());
                        }
                    }
                }
            } else if (method != null && method.isAnnotationPresent(OPermission.class)) {
                OPermission oPermission = method.getAnnotation(OPermission.class);
                final Annotation[][] paramAnnotations = method.getParameterAnnotations();
                final Class[] paramTypes = method.getParameterTypes();

                if (oPermission != null
                        && paramAnnotations[0][0] instanceof co.omkar.utility.opermission.annotation.Result
                        && (paramTypes[0] == boolean.class
                        || paramTypes[0] == Boolean.class)) {

                    /* Check single value annotations */
                    for (Map.Entry<Permission, Result> permResult : resultMap.entrySet()) {

                        // invoke method if String permission is annotated.
                        if (oPermission.permission().equals(permResult.getKey().toString())
                                || oPermission.value().equals(permResult.getKey())) {

                            switch (permResult.getValue()) {

                                // Permission is granted.
                                case GRANTED:
                                    method.invoke(getBase(), true);
                                    mLog.i(TAG, "invoking method: " + method.getName());
                                    break;

                                // Permission is denied.
                                case DENIED:
                                    method.invoke(getBase(), false);
                                    mLog.i(TAG, "invoking method: " + method.getName());
                                    break;
                            }
                        }
                    }

                        /* Check array fields in annotations */
                    if (oPermission.values().length > 0) {
                        if (allValuesGranted(oPermission.values(), resultMap)) {
                            method.invoke(getBase(), true);
                            mLog.i(TAG, "invoking as granted method: " + method.getName());
                        } else {
                            method.invoke(getBase(), false);
                            mLog.i(TAG, "invoking as denied method: " + method.getName());
                        }
                        continue;
                    }

                    if (oPermission.permissions().length > 0) {
                        if (allValuesGranted(oPermission.permissions(), resultMap)) {
                            method.invoke(getBase(), true);
                            mLog.i(TAG, "invoking as granted method: " + method.getName());
                        } else {
                            method.invoke(getBase(), false);
                            mLog.i(TAG, "invoking as denied method: " + method.getName());
                        }
                    }
                }
            }

        }
    }
private static void invokeAnnotatedMethods(HashMap<Permission, Result> resultMap)
            throws InvocationTargetException, IllegalAccessException {
        Method[] methods = getBase().getClass().getDeclaredMethods();

        // check all methods from provided class or by default provided activity.
        for (Method method : methods) {

            if (method != null && method.isAnnotationPresent(GrantedPermission.class)) {
                GrantedPermission granted = method.getAnnotation(GrantedPermission.class);

                if (granted != null) {

                    /* Check single value annotations */
                    if (!granted.permission().equals("") || granted.value() != Permission.NONE) {
                        for (Map.Entry<Permission, Result> permResult : resultMap.entrySet()) {

                            // invoke method if String permission is annotated.
                            if ((granted.permission().equals(permResult.getKey().toString()) ||
                                    granted.value() == permResult.getKey())
                                    && Result.GRANTED == permResult.getValue()) {
                                method.invoke(getBase());
                                mLog.i(TAG, "invoking grant method: " + method.getName());
                            }
                        }
                        continue;
                    }

                    /* Check array fields in annotations */
                    if (granted.values().length > 0) {
                        if (allValuesGranted(granted.values(), resultMap)) {
                            method.invoke(getBase());
                            mLog.i(TAG, "invoking grant method: " + method.getName());
                        }
                        continue;
                    }

                    if (granted.permissions().length > 0) {
                        if (allValuesGranted(granted.permissions(), resultMap)) {
                            method.invoke(getBase());
                            mLog.i(TAG, "invoking grant method: " + method.getName());
                        }
                    }
                }
            } else if (method != null && method.isAnnotationPresent(DeniedPermission.class)) {
                DeniedPermission denied = method.getAnnotation(DeniedPermission.class);

                if (denied != null) {

                    /* Check single value annotations */
                    if (!denied.permission().equals("") || denied.value() != Permission.NONE) {
                        for (Map.Entry<Permission, Result> permResult : resultMap.entrySet()) {

                            // invoke method if String permission is annotated.
                            if ((denied.permission().equals(permResult.getKey().toString())
                                    || denied.value() == permResult.getKey())
                                    && Result.DENIED == permResult.getValue()) {
                                method.invoke(getBase());
                                mLog.i(TAG, "invoking denied method: " + method.getName());
                            }
                        }
                        continue;
                    }

                    /* Check array fields in annotations */
                    if (denied.values().length > 0) {
                        if (anyValueDenied(denied.values(), resultMap)) {
                            method.invoke(getBase());
                            mLog.i(TAG, "invoking denied method: " + method.getName());
                        }
                        continue;
                    }

                    if (denied.permissions().length > 0) {
                        if (anyValueDenied(denied.permissions(), resultMap)) {
                            mLog.i(TAG, "invoking denied method: " + method.getName());
                            method.invoke(getBase());
                        }
                    }
                }
            } else if (method != null && method.isAnnotationPresent(OPermission.class)) {
                OPermission oPermission = method.getAnnotation(OPermission.class);
                final Annotation[][] paramAnnotations = method.getParameterAnnotations();
                final Class[] paramTypes = method.getParameterTypes();

                if (oPermission != null
                        && paramAnnotations[0][0] instanceof co.omkar.utility.opermission.annotation.Result
                        && (paramTypes[0] == boolean.class
                        || paramTypes[0] == Boolean.class)) {

                    /* Check single value annotations */
                    for (Map.Entry<Permission, Result> permResult : resultMap.entrySet()) {

                        // invoke method if String permission is annotated.
                        if (oPermission.permission().equals(permResult.getKey().toString())
                                || oPermission.value().equals(permResult.getKey())) {

                            switch (permResult.getValue()) {

                                // Permission is granted.
                                case GRANTED:
                                    method.invoke(getBase(), true);
                                    mLog.i(TAG, "invoking method: " + method.getName());
                                    break;

                                // Permission is denied.
                                case DENIED:
                                    method.invoke(getBase(), false);
                                    mLog.i(TAG, "invoking method: " + method.getName());
                                    break;
                            }
                        }
                    }

                        /* Check array fields in annotations */
                    if (oPermission.values().length > 0) {
                        if (allValuesGranted(oPermission.values(), resultMap)) {
                            method.invoke(getBase(), true);
                            mLog.i(TAG, "invoking as granted method: " + method.getName());
                        } else {
                            method.invoke(getBase(), false);
                            mLog.i(TAG, "invoking as denied method: " + method.getName());
                        }
                        continue;
                    }

                    if (oPermission.permissions().length > 0) {
                        if (allValuesGranted(oPermission.permissions(), resultMap)) {
                            method.invoke(getBase(), true);
                            mLog.i(TAG, "invoking as granted method: " + method.getName());
                        } else {
                            method.invoke(getBase(), false);
                            mLog.i(TAG, "invoking as denied method: " + method.getName());
                        }
                    }
                }
            }

        }
    }
Invoke annotated methods in provided class.

@param resultMap prepared Map of Permissions and respective results.
@throws InvocationTargetException
@throws IllegalAccessException