/** Get the argument types of this method. loosely typed (untyped) arguments will be represented by null argument types. */ /* Note: bshmethod needs to re-evaluate arg types here This is broken. */ public Class<?> [] getParameterTypes() { if (null == this.javaMethod) return cparamTypes; return this.javaMethod.getParameterTypes(); }
/** Retrieve a method type from return type a parameter type signatures. * @return method type */ public MethodType methodType() { return MethodType.methodType(getReturnType(), getParameterTypes()); }
/** Basic parameter collection with pulling inherited cascade chaining. */ public List<Object> collectParamaters(Object base, Object[] params) throws Throwable { parameters.clear(); for (int i = 0; i < getLastParameterIndex(); i++) parameters.add(coerceToType(params[i], getParameterTypes()[i])); return parameters; }
/** {@inheritDoc} */ @Override public int hashCode() { return getClass().hashCode() ^ getName().hashCode() ^ getDeclaringClass().hashCode() ^ getParameterCount() ^ getReturnType().hashCode() ^ getModifiers() ^ Stream.of(getParameterTypes()) .map(t -> null == t ? 39 : t.hashCode()) .reduce(75, (a, b) -> a ^ b).intValue(); } }
public Class<?>[] getParameterTypes() { if ( null != this.constructor ) return this.constructor.getParameterTypes(); // BSHFormalParameters will cache the type for us try { return (Class [])paramTypesNode.eval( callstack, interpreter ); } catch ( EvalError e ) { throw new InterpreterError("can't eval param types: "+e, e); } }
BshMethod( Invocable method, Object object ) { this( method.getName(), method.getReturnType(), null/*paramNames*/, method.getParameterTypes(), null/*paramModifiers*/, null/*method.block*/, null/*declaringNameSpace*/, null/*modifiers*/ ); this.javaMethod = method; this.javaObject = object; }
List<Invocable> methodList = new ArrayList<>(); for( Invocable method : methods ) { Class<?>[] parameterTypes = method.getParameterTypes(); methodList.add( method ); candidateSigs.add( parameterTypes );
private static void checkFoundStaticMethod( Invocable method, boolean staticOnly, Class<?> clas ) throws UtilEvalError { // We're looking for a static method but found an instance method if ( method != null && staticOnly && !method.isStatic() ) throw new UtilEvalError( "Cannot reach instance method: " + StringUtil.methodString( method.getName(), method.getParameterTypes() ) + " from static context: "+ clas.getName() ); }
/** {@inheritDoc} */ @Override public boolean equals(Object o) { if (o == null) return false; if (this == o) return true; if (this.getClass() != o.getClass()) return false; Invocable member = (Invocable) o; if (!getName().equals(member.getName()) || getDeclaringClass() != member.getDeclaringClass() || getParameterCount() != member.getParameterCount() || getReturnType() != member.getReturnType() || getModifiers() != member.getModifiers()) return false; for (int i = 0; i < getParameterCount(); i++) if (getParameterTypes()[i] != member.getParameterTypes()[i]) return false; return true; }