Java Code Examples for org.springframework.util.ReflectionUtils#isHashCodeMethod()

The following examples show how to use org.springframework.util.ReflectionUtils#isHashCodeMethod() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-analysis-note   File: BshScriptUtils.java    License: MIT License 6 votes vote down vote up
@Override
@Nullable
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	if (ReflectionUtils.isEqualsMethod(method)) {
		return (isProxyForSameBshObject(args[0]));
	}
	else if (ReflectionUtils.isHashCodeMethod(method)) {
		return this.xt.hashCode();
	}
	else if (ReflectionUtils.isToStringMethod(method)) {
		return "BeanShell object [" + this.xt + "]";
	}
	try {
		Object result = this.xt.invokeMethod(method.getName(), args);
		if (result == Primitive.NULL || result == Primitive.VOID) {
			return null;
		}
		if (result instanceof Primitive) {
			return ((Primitive) result).getValue();
		}
		return result;
	}
	catch (EvalError ex) {
		throw new BshExecutionException(ex);
	}
}
 
Example 2
@Override
public Object invoke(Object proxy, Method method, Object[] args) {
	if (ReflectionUtils.isEqualsMethod(method)) {
		return annotationEquals(args[0]);
	}
	if (ReflectionUtils.isHashCodeMethod(method)) {
		return annotationHashCode();
	}
	if (ReflectionUtils.isToStringMethod(method)) {
		return this.annotation.toString();
	}
	if (isAnnotationTypeMethod(method)) {
		return this.type;
	}
	if (this.attributes.indexOf(method.getName()) != -1) {
		return getAttributeValue(method);
	}
	throw new AnnotationConfigurationException(String.format(
			"Method [%s] is unsupported for synthesized annotation type [%s]", method, this.type));
}
 
Example 3
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	if (ReflectionUtils.isEqualsMethod(method)) {
		// Only consider equal when proxies are identical.
		return (proxy == args[0]);
	}
	else if (ReflectionUtils.isHashCodeMethod(method)) {
		// Use hashCode of service locator proxy.
		return System.identityHashCode(proxy);
	}
	else if (ReflectionUtils.isToStringMethod(method)) {
		return "Service locator: " + serviceLocatorInterface.getName();
	}
	else {
		return invokeServiceLocatorMethod(method, args);
	}
}
 
Example 4
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	if (ReflectionUtils.isEqualsMethod(method)) {
		// Only consider equal when proxies are identical.
		return (proxy == args[0]);
	}
	else if (ReflectionUtils.isHashCodeMethod(method)) {
		// Use hashCode of service locator proxy.
		return System.identityHashCode(proxy);
	}
	else if (ReflectionUtils.isToStringMethod(method)) {
		return "Service locator: " + serviceLocatorInterface;
	}
	else {
		return invokeServiceLocatorMethod(method, args);
	}
}
 
Example 5
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	if (ReflectionUtils.isEqualsMethod(method)) {
		// Only consider equal when proxies are identical.
		return (proxy == args[0]);
	}
	else if (ReflectionUtils.isHashCodeMethod(method)) {
		// Use hashCode of reference proxy.
		return System.identityHashCode(proxy);
	}
	else if (!initialized && ReflectionUtils.isToStringMethod(method)) {
		return "Early singleton proxy for interfaces " +
				ObjectUtils.nullSafeToString(getEarlySingletonInterfaces());
	}
	try {
		return method.invoke(getSingletonInstance(), args);
	}
	catch (InvocationTargetException ex) {
		throw ex.getTargetException();
	}
}
 
Example 6
Source Project: java-technology-stack   File: BshScriptUtils.java    License: MIT License 6 votes vote down vote up
@Override
@Nullable
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	if (ReflectionUtils.isEqualsMethod(method)) {
		return (isProxyForSameBshObject(args[0]));
	}
	else if (ReflectionUtils.isHashCodeMethod(method)) {
		return this.xt.hashCode();
	}
	else if (ReflectionUtils.isToStringMethod(method)) {
		return "BeanShell object [" + this.xt + "]";
	}
	try {
		Object result = this.xt.invokeMethod(method.getName(), args);
		if (result == Primitive.NULL || result == Primitive.VOID) {
			return null;
		}
		if (result instanceof Primitive) {
			return ((Primitive) result).getValue();
		}
		return result;
	}
	catch (EvalError ex) {
		throw new BshExecutionException(ex);
	}
}
 
Example 7
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	if (ReflectionUtils.isEqualsMethod(method)) {
		return annotationEquals(args[0]);
	}
	if (ReflectionUtils.isHashCodeMethod(method)) {
		return annotationHashCode();
	}
	if (ReflectionUtils.isToStringMethod(method)) {
		return annotationToString();
	}
	if (AnnotationUtils.isAnnotationTypeMethod(method)) {
		return annotationType();
	}
	if (!AnnotationUtils.isAttributeMethod(method)) {
		throw new AnnotationConfigurationException(String.format(
				"Method [%s] is unsupported for synthesized annotation type [%s]", method, annotationType()));
	}
	return getAttributeValue(method);
}
 
Example 8
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	if (ReflectionUtils.isEqualsMethod(method)) {
		// Only consider equal when proxies are identical.
		return (proxy == args[0]);
	}
	else if (ReflectionUtils.isHashCodeMethod(method)) {
		// Use hashCode of reference proxy.
		return System.identityHashCode(proxy);
	}
	else if (!initialized && ReflectionUtils.isToStringMethod(method)) {
		return "Early singleton proxy for interfaces " +
				ObjectUtils.nullSafeToString(getEarlySingletonInterfaces());
	}
	try {
		return method.invoke(getSingletonInstance(), args);
	}
	catch (InvocationTargetException ex) {
		throw ex.getTargetException();
	}
}
 
Example 9
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	if (ReflectionUtils.isEqualsMethod(method)) {
		// Only consider equal when proxies are identical.
		return (proxy == args[0]);
	}
	else if (ReflectionUtils.isHashCodeMethod(method)) {
		// Use hashCode of service locator proxy.
		return System.identityHashCode(proxy);
	}
	else if (ReflectionUtils.isToStringMethod(method)) {
		return "Service locator: " + serviceLocatorInterface;
	}
	else {
		return invokeServiceLocatorMethod(method, args);
	}
}
 
Example 10
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	if (ReflectionUtils.isEqualsMethod(method)) {
		return (isProxyForSameRubyObject(args[0]));
	}
	else if (ReflectionUtils.isHashCodeMethod(method)) {
		return this.rubyObject.hashCode();
	}
	else if (ReflectionUtils.isToStringMethod(method)) {
		String toStringResult = this.rubyObject.toString();
		if (!StringUtils.hasText(toStringResult)) {
			toStringResult = ObjectUtils.identityToString(this.rubyObject);
		}
		return "JRuby object [" + toStringResult + "]";
	}
	try {
		IRubyObject[] rubyArgs = convertToRuby(args);
		IRubyObject rubyResult =
				this.rubyObject.callMethod(this.ruby.getCurrentContext(), method.getName(), rubyArgs);
		return convertFromRuby(rubyResult, method.getReturnType());
	}
	catch (RaiseException ex) {
		throw new JRubyExecutionException(ex);
	}
}
 
Example 11
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	if (ReflectionUtils.isEqualsMethod(method)) {
		return (isProxyForSameBshObject(args[0]));
	}
	else if (ReflectionUtils.isHashCodeMethod(method)) {
		return this.xt.hashCode();
	}
	else if (ReflectionUtils.isToStringMethod(method)) {
		return "BeanShell object [" + this.xt + "]";
	}
	try {
		Object result = this.xt.invokeMethod(method.getName(), args);
		if (result == Primitive.NULL || result == Primitive.VOID) {
			return null;
		}
		if (result instanceof Primitive) {
			return ((Primitive) result).getValue();
		}
		return result;
	}
	catch (EvalError ex) {
		throw new BshExecutionException(ex);
	}
}
 
Example 12
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	if (ReflectionUtils.isEqualsMethod(method)) {
		// Only consider equal when proxies are identical.
		return (proxy == args[0]);
	}
	else if (ReflectionUtils.isHashCodeMethod(method)) {
		// Use hashCode of reference proxy.
		return System.identityHashCode(proxy);
	}
	else if (!initialized && ReflectionUtils.isToStringMethod(method)) {
		return "Early singleton proxy for interfaces " +
				ObjectUtils.nullSafeToString(getEarlySingletonInterfaces());
	}
	try {
		return method.invoke(getSingletonInstance(), args);
	}
	catch (InvocationTargetException ex) {
		throw ex.getTargetException();
	}
}
 
Example 13
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	if (ReflectionUtils.isEqualsMethod(method)) {
		// Only consider equal when proxies are identical.
		return (proxy == args[0]);
	}
	else if (ReflectionUtils.isHashCodeMethod(method)) {
		// Use hashCode of service locator proxy.
		return System.identityHashCode(proxy);
	}
	else if (ReflectionUtils.isToStringMethod(method)) {
		return "Service locator: " + serviceLocatorInterface;
	}
	else {
		return invokeServiceLocatorMethod(method, args);
	}
}
 
Example 14
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	if (ReflectionUtils.isEqualsMethod(method)) {
		return (isProxyForSameBshObject(args[0]));
	}
	else if (ReflectionUtils.isHashCodeMethod(method)) {
		return this.xt.hashCode();
	}
	else if (ReflectionUtils.isToStringMethod(method)) {
		return "BeanShell object [" + this.xt + "]";
	}
	try {
		Object result = this.xt.invokeMethod(method.getName(), args);
		if (result == Primitive.NULL || result == Primitive.VOID) {
			return null;
		}
		if (result instanceof Primitive) {
			return ((Primitive) result).getValue();
		}
		return result;
	}
	catch (EvalError ex) {
		throw new BshExecutionException(ex);
	}
}
 
Example 15
Source Project: blog_demos   File: AbstractFactoryBean.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	if (ReflectionUtils.isEqualsMethod(method)) {
		// Only consider equal when proxies are identical.
		return (proxy == args[0]);
	}
	else if (ReflectionUtils.isHashCodeMethod(method)) {
		// Use hashCode of reference proxy.
		return System.identityHashCode(proxy);
	}
	else if (!initialized && ReflectionUtils.isToStringMethod(method)) {
		return "Early singleton proxy for interfaces " +
				ObjectUtils.nullSafeToString(getEarlySingletonInterfaces());
	}
	try {
		return method.invoke(getSingletonInstance(), args);
	}
	catch (InvocationTargetException ex) {
		throw ex.getTargetException();
	}
}
 
Example 16
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	if (ReflectionUtils.isEqualsMethod(method)) {
		// Only consider equal when proxies are identical.
		return (proxy == args[0]);
	}
	else if (ReflectionUtils.isHashCodeMethod(method)) {
		// Use hashCode of service locator proxy.
		return System.identityHashCode(proxy);
	}
	else if (ReflectionUtils.isToStringMethod(method)) {
		return "Service locator: " + serviceLocatorInterface.getName();
	}
	else {
		return invokeServiceLocatorMethod(method, args);
	}
}
 
Example 17
Source Project: spring-data   File: AbstractResolver.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object intercept(final Object obj, final Method method, final Object[] args, final MethodProxy proxy)
		throws Throwable {

	if (GET_ENTITY_METHOD.equals(method)) {
		return ensureResolved();
	}

	if (GET_REF_ID_METHOD.equals(method)) {
		return id;
	}

	if (ReflectionUtils.isObjectMethod(method)) {
		if (ReflectionUtils.isToStringMethod(method)) {
			return proxyToString();
		}

		else if (ReflectionUtils.isEqualsMethod(method)) {
			return proxyEquals(proxy, args[0]);
		}

		else if (ReflectionUtils.isHashCodeMethod(method)) {
			return proxyHashCode();
		}
	}

	final Object result = ensureResolved();
	return result == null ? null : method.invoke(result, args);
}
 
Example 18
Source Project: spring-analysis-note   File: AopUtils.java    License: MIT License 2 votes vote down vote up
/**
 * Determine whether the given method is a "hashCode" method.
 * @see java.lang.Object#hashCode
 */
public static boolean isHashCodeMethod(@Nullable Method method) {
	return ReflectionUtils.isHashCodeMethod(method);
}
 
Example 19
Source Project: lams   File: AopUtils.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * Determine whether the given method is a "hashCode" method.
 * @see java.lang.Object#hashCode
 */
public static boolean isHashCodeMethod(Method method) {
	return ReflectionUtils.isHashCodeMethod(method);
}
 
Example 20
Source Project: spring4-understanding   File: AopUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Determine whether the given method is a "hashCode" method.
 * @see java.lang.Object#hashCode
 */
public static boolean isHashCodeMethod(Method method) {
	return ReflectionUtils.isHashCodeMethod(method);
}