/** * Determines if the method represents a recursion call (i.e. whether the method call is already * in the cache.) * * @return True if the call is part of a recursion */ public boolean isRecursive() { MethodWrapper current = getParent(); while (current != null) { if (getMember().getHandleIdentifier().equals(current.getMember().getHandleIdentifier())) { return true; } current = current.getParent(); } return false; }
/** Constructor CallerElement. */ public MethodWrapper(MethodWrapper parent, MethodCall methodCall) { Assert.isNotNull(methodCall); if (parent == null) { setMethodCache(new HashMap()); fLevel = 1; } else { setMethodCache(parent.getMethodCache()); fLevel = parent.getLevel() + 1; } this.fMethodCall = methodCall; this.fParent = parent; }
@Override public boolean equals(Object oth) { if (this == oth) { return true; } if (oth == null) { return false; } if (oth instanceof MethodWrapperWorkbenchAdapter) { // Note: A MethodWrapper is equal to a referring MethodWrapperWorkbenchAdapter and vice versa // (bug 101677). oth = ((MethodWrapperWorkbenchAdapter) oth).getMethodWrapper(); } if (oth.getClass() != getClass()) { return false; } MethodWrapper other = (MethodWrapper) oth; if (this.fParent == null) { if (other.fParent != null) { return false; } } else { if (!this.fParent.equals(other.fParent)) { return false; } } if (this.getMethodCall() == null) { if (other.getMethodCall() != null) { return false; } } else { if (!this.getMethodCall().equals(other.getMethodCall())) { return false; } } return true; }
@Override public int hashCode() { final int PRIME = 1000003; int result = 0; if (fParent != null) { result = (PRIME * result) + fParent.hashCode(); } if (getMethodCall() != null) { result = (PRIME * result) + getMethodCall().getMember().hashCode(); } return result; }