public String getName() { if (null == this.javaMethod) return name; return this.javaMethod.getName(); }
public String getName() { if ( null != field ) return field.getName(); if ( null != var ) return var.getName(); return varName; }
/** Reflect Field is not serializable, hide it. * @param s serializer * @throws IOException mandatory throwing exception */ private synchronized void writeObject(final ObjectOutputStream s) throws IOException { if ( null != field ) { this.object = field.getDeclaringClass(); this.varName = field.getName(); this.field = null; } s.defaultWriteObject(); }
/** {@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(); } }
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; }
/** Cache constructors and methods. * Identifies properties and caches an additional cache entry * referenced by property name, as defined by bean specification. * @param member to cache * @return true if the cache changed */ private boolean cacheMember(Invocable member) { if (null == member) return false; if (!member.isGetter() && !member.isSetter()) return cacheMember(member.getName(), member); String name = member.getName(); String propName = name.replaceFirst("[gs]et|is", ""); if (propName.length() == 1 // double caps are skipped || Character.isLowerCase(name.charAt(1))) { char[] ch = propName.toCharArray(); ch[0] = Character.toLowerCase(ch[0]); propName = new String(ch); } return cacheMember(name, member) && cacheMember(propName, member); }
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; }