app/src/main/java/db/juhaku/juhakudb/repository/RepositoryFactory.java
/**
             * Find method with same erasure as is being executed in proxy interface. Method is
             * checked by name, return type and parameter types and order or parameter types.
             *
             * @param method Method to look for.
             * @return Found method or null.
             *
             * @since 1.3.0
             *
             * @hide
             */
Find method with same erasure as is being executed in proxy interface. Method is
checked by name, return type and parameter types and order or parameter types.

@param method Method to look for.
@return Found method or null.



@hide
Find method with same erasure as is being executed in proxy interface . Method is checked by name return type and parameter types and order or parameter types . @param method Method to look for . @return Found method or null . @hide
private Method findMethodWithSameErasure(Method method) {
                for (Method m : simpleAndroidRepository.getClass().getMethods()) {
                    boolean accessible = m.isAccessible();
                    m.setAccessible(true);
                    if (m.getName().equals(method.getName()) && m.getReturnType().equals(method.getReturnType())) {
                        boolean hasParams = true;
                        for (int i = 0; i < m.getParameterTypes().length; i++) {
                            if (m.getParameterTypes()[i].equals(method.getParameterTypes()[i])) {
                                continue;
                            }
                            hasParams = false;
                            break;
                        }
                        if (hasParams) {
                            return m;
                        }
                    }
                    m.setAccessible(accessible);
                }
                return null;
            }
private Method findMethodWithSameErasure ( Method method ) { for ( Method m : simpleAndroidRepository . getClass ( ) . getMethods ( ) ) { boolean accessible = m . isAccessible ( ) ; m . setAccessible ( true ) ; if ( m . getName ( ) . equals ( method . getName ( ) ) && m . getReturnType ( ) . equals ( method . getReturnType ( ) ) ) { boolean hasParams = true ; for ( int i = 0 ; i < m . getParameterTypes ( ) . length ; i ++ ) { if ( m . getParameterTypes ( ) [ i ] . equals ( method . getParameterTypes ( ) [ i ] ) ) { continue ; } hasParams = false ; break ; } if ( hasParams ) { return m ; } } m . setAccessible ( accessible ) ; } return null ; }
Find method with same erasure as is being executed in proxy interface.
Find method with same erasure as is being executed in proxy interface .
// Set method accessible. // Check that we have right method by name and return type. // Check that method has same amount of parameters with same classes. // If all the parameters are same execution can be processed. // Restore default accessible status.