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

The following examples show how to use org.springframework.util.ReflectionUtils#isEqualsMethod() . 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) 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 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 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 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
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 6
@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 7
@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 8
@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 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 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 10
@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 11
@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 12
@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 13
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 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
/**
 * Handles reflective method invocation, either invoking a method on the proxy
 * (equals or hashcode) or directly on the target. Implementation copied from
 * spring framework ServiceLocationInvocationHandler
 * 
 * @param proxy Object to proxy
 * @param method Method in object to proxy
 * @param args Method arguments
 * @return Return value of method invocation, if any
 * @throws InvocationTargetException just passing on
 * @throws IllegalAccessException just passing on
 */
protected Object handleSelfMethodInvocation(Object proxy, Method method, Object[] args)
		throws InvocationTargetException, IllegalAccessException {
	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 remoteServiceInterfaceClass.getName() + "@" + System.identityHashCode(proxy);
	} else {
		return method.invoke(this, args);
	}
}
 
Example 16
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 17
Source Project: spring-analysis-note   File: AopUtils.java    License: MIT License 2 votes vote down vote up
/**
 * Determine whether the given method is an "equals" method.
 * @see java.lang.Object#equals
 */
public static boolean isEqualsMethod(@Nullable Method method) {
	return ReflectionUtils.isEqualsMethod(method);
}
 
Example 18
Source Project: java-technology-stack   File: AopUtils.java    License: MIT License 2 votes vote down vote up
/**
 * Determine whether the given method is an "equals" method.
 * @see java.lang.Object#equals
 */
public static boolean isEqualsMethod(@Nullable Method method) {
	return ReflectionUtils.isEqualsMethod(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 an "equals" method.
 * @see java.lang.Object#equals
 */
public static boolean isEqualsMethod(Method method) {
	return ReflectionUtils.isEqualsMethod(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 an "equals" method.
 * @see java.lang.Object#equals
 */
public static boolean isEqualsMethod(Method method) {
	return ReflectionUtils.isEqualsMethod(method);
}