/** {@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 boolean hasModifier( String name ) { if ( javaMethod != null ) return Reflect.hasModifier(name, javaMethod.getModifiers()); return modifiers != null && modifiers.hasModifier(name); }
/** {@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; }
/** This method wraps resolveJavaMethod() and expects a non-null method result. If the method is not found it throws a descriptive ReflectError. */ protected static Invocable resolveExpectedJavaMethod( BshClassManager bcm, Class<?> clas, Object object, String name, Object[] args, boolean staticOnly ) throws ReflectError, UtilEvalError { if ( object == Primitive.NULL ) throw new UtilTargetError( new NullPointerException( "Attempt to invoke method " +name+" on null value" ) ); Class<?>[] types = Types.getTypes(args); Invocable method = resolveJavaMethod( clas, name, types, staticOnly ); if ( null != bcm && bcm.getStrictJava() && method != null && method.getDeclaringClass().isInterface() && method.getDeclaringClass() != clas && Modifier.isStatic(method.getModifiers())) // static interface methods are class only method = null; if ( method == null ) throw new ReflectError( ( staticOnly ? "Static method " : "Method " ) + StringUtil.methodString(name, types) + " not found in class'" + clas.getName() + "'"); return method; }