package com.ryantenney.metrics.spring;

import java.lang.reflect.Method;
import java.util.Arrays;

class MethodKey {
	private final String name;
	private final Class<?> returnType;
	private final Class<?>[] parameterTypes;
	private final int hashCode;

	public static MethodKey forMethod(Method method) {
		return new MethodKey(method);
	}

	private MethodKey(Method method) {
		this.name = method.getName();
		this.returnType = method.getReturnType();
		this.parameterTypes = method.getParameterTypes();
		this.hashCode = computeHashCode();
	}

	@Override
	public int hashCode() {
		return hashCode;
	}

	private int computeHashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (name == null ? 0 : name.hashCode());
		result = prime * result + Arrays.hashCode(parameterTypes);
		result = prime * result + (returnType == null ? 0 : returnType.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		MethodKey other = (MethodKey) obj;
		if (name == null) {
			if (other.name != null) {
				return false;
			}
		}
		else if (!name.equals(other.name)) {
			return false;
		}
		if (!Arrays.equals(parameterTypes, other.parameterTypes)) {
			return false;
		}
		if (returnType == null) {
			if (other.returnType != null) {
				return false;
			}
		}
		else if (!returnType.equals(other.returnType)) {
			return false;
		}
		return true;
	}

}

@@ -110,16 +110,17 @@
 odKey %7B%0A
+%0A
 %09private
@@ -1529,10 +1529,446 @@
 ue;%0A%09%7D%0A%0A
+%09@Override%0A%09public String toString() %7B%0A%09%09StringBuilder sb = new StringBuilder(64);%0A%09%09sb.append(returnType.getSimpleName());%0A%09%09sb.append(' ');%0A%09%09sb.append(name);%0A%09%09sb.append('(');%0A%09%09boolean firstParam = true;%0A%09%09for (Class%3C?%3E parameterType : parameterTypes) %7B%0A%09%09%09if (firstParam) %7B%0A%09%09%09%09firstParam = false;%0A%09%09%09%7D else %7B%0A%09%09%09%09sb.append(%22, %22);%0A%09%09%09%7D%0A%09%09%09sb.append(parameterType.getSimpleName());%0A%09%09%7D%0A%09%09sb.append(')');%0A%09%09return sb.toString();%0A%09%7D%0A%0A
 %7D%0A

Add MethodKey.toString