/** * Returns whether or not this method is protected. * @return true if this method is protected */ public final boolean isProtected() { return (getModifiers() & Modifier.PROTECTED) != 0; }
/** * Returns whether or not this method is static. * @return true if this method is static */ public boolean isStatic() { return (getModifiers() & Modifier.STATIC) != 0; }
/** * Returns whether or not this method is abstract. * @return true if this method is abstract */ public boolean isAbstract() { return (getModifiers() & Modifier.ABSTRACT) != 0; }
/** * Returns whether or not this method is private. * @return true if this method is private */ public final boolean isPrivate() { return (getModifiers() & Modifier.PRIVATE) != 0; }
/** * Returns whether or not this method is public. * @return true if this method is public */ public final boolean isPublic() { return (getModifiers() & Modifier.PUBLIC) != 0; }
public int getModifiers() { return method.getModifiers(); }
public int getModifiers() { return metaMethod.getModifiers(); }
private void addToAllMethodsIfPublic(MetaMethod metaMethod) { if (Modifier.isPublic(metaMethod.getModifiers())) allMethods.add(metaMethod); }
/** * Gets the visibility modifiers for the property as defined by the getter and setter methods. * * @return the visibility modifier of the getter, the setter, or both depending on which exist */ public int getModifiers() { MetaMethod getter = getGetter(); MetaMethod setter = getSetter(); if (setter != null && getter == null) return setter.getModifiers(); if (getter != null && setter == null) return getter.getModifiers(); int modifiers = getter.getModifiers() | setter.getModifiers(); int visibility = 0; if (Modifier.isPublic(modifiers)) visibility = Modifier.PUBLIC; if (Modifier.isProtected(modifiers)) visibility = Modifier.PROTECTED; if (Modifier.isPrivate(modifiers)) visibility = Modifier.PRIVATE; int states = getter.getModifiers() & setter.getModifiers(); states &= ~(Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE); states |= visibility; return states; }
/** *Returns true if this this metamethod represents the same method as the argument. * * @param method A metaMethod instance * @return true if method is for the same method as this method, false otherwise. */ public boolean isMethod(MetaMethod method) { return getName().equals(method.getName()) && getModifiers() == method.getModifiers() && getReturnType().equals(method.getReturnType()) && equal(getParameterTypes(), method.getParameterTypes()); }
private void appendMethods(StringBuilder buffer) { for (int i = 0; i < methods.size; i++) { buffer.append("\n "); Object methodOrConstructor = methods.get(i); if (methodOrConstructor instanceof MetaMethod) { MetaMethod method = (MetaMethod) methodOrConstructor; buffer.append(Modifier.toString(method.getModifiers())); buffer.append(" ").append(method.getReturnType().getName()); buffer.append(" ").append(method.getDeclaringClass().getName()); buffer.append("#"); buffer.append(method.getName()); appendClassNames(buffer,method.getNativeParameterTypes()); } else { CachedConstructor method = (CachedConstructor) methodOrConstructor; buffer.append(Modifier.toString(method.cachedConstructor.getModifiers())); buffer.append(" ").append(method.cachedConstructor.getDeclaringClass().getName()); buffer.append("#<init>"); appendClassNames(buffer,method.getNativeParameterTypes()); } } } }
/** * @param method the method to compare against * @return true if the given method has the same name, parameters, return type * and modifiers but may be defined on another type */ public final boolean isSame(MetaMethod method) { return getName().equals(method.getName()) && compatibleModifiers(getModifiers(), method.getModifiers()) && getReturnType().equals(method.getReturnType()) && equal(getParameterTypes(), method.getParameterTypes()); }
public String getMopName() { if (mopName == null) { String name = getName(); CachedClass declaringClass = getDeclaringClass(); if (Modifier.isPrivate(getModifiers())) mopName = "this$" + declaringClass.getSuperClassDistance() + "$" + name; else mopName = "super$" + declaringClass.getSuperClassDistance() + "$" + name; } return mopName; }
protected String[] methodInfo(MetaMethod method) { String[] result = new String[MEMBER_EXCEPTIONS_IDX + 1]; int mod = method.getModifiers(); result[MEMBER_ORIGIN_IDX] = GROOVY; result[MEMBER_MODIFIER_IDX] = Modifier.toString(mod); result[MEMBER_DECLARER_IDX] = shortName(method.getDeclaringClass().getTheClass()); result[MEMBER_TYPE_IDX] = shortName(method.getReturnType()); result[MEMBER_NAME_IDX] = method.getName(); result[MEMBER_PARAMS_IDX] = makeParamsInfo(method.getNativeParameterTypes()); result[MEMBER_EXCEPTIONS_IDX] = NOT_APPLICABLE; // no exception info for Groovy MetaMethods return withoutNulls(result); }
final int mod = method.getModifiers();
public String getMopName() { if (mopName == null) { String name = getName(); CachedClass declaringClass = getDeclaringClass(); if (Modifier.isPrivate(getModifiers())) mopName = new StringBuffer().append("this$").append(declaringClass.getSuperClassDistance()).append("$").append(name).toString(); else mopName = new StringBuffer().append("super$").append(declaringClass.getSuperClassDistance()).append("$").append(name).toString(); } return mopName; }
public String getMopName() { if (mopName == null) { String name = getName(); CachedClass declaringClass = getDeclaringClass(); if ((getModifiers() & (Modifier.PUBLIC| Modifier.PROTECTED)) == 0) mopName = new StringBuffer().append("this$").append(declaringClass.getSuperClassDistance()).append("$").append(name).toString(); else mopName = new StringBuffer().append("super$").append(declaringClass.getSuperClassDistance()).append("$").append(name).toString(); } return mopName; }
public String getMopName() { if (mopName == null) { String name = getName(); CachedClass declaringClass = getDeclaringClass(); if ((getModifiers() & (Modifier.PUBLIC| Modifier.PROTECTED)) == 0) mopName = new StringBuffer().append("this$").append(declaringClass.getSuperClassDistance()).append("$").append(name).toString(); else mopName = new StringBuffer().append("super$").append(declaringClass.getSuperClassDistance()).append("$").append(name).toString(); } return mopName; }
public boolean isMethod(MetaMethod method) { return getName().equals(method.getName()) && getModifiers() == method.getModifiers() && getReturnType().equals(method.getReturnType()) && equal(getParameterTypes(), method.getParameterTypes()); }
/** * @param method the method to compare against * @return true if the given method has the same name, parameters, return type * and modifiers but may be defined on another type */ public final boolean isSame(MetaMethod method) { return getName().equals(method.getName()) && compatibleModifiers(getModifiers(), method.getModifiers()) && getReturnType().equals(method.getReturnType()) && equal(getParameterTypes(), method.getParameterTypes()); }