All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jodd.methref.MethrefAdvice Maven / Gradle / Ivy

Go to download

Jodd Proxetta is the fastest proxy creator with unique approach for defying pointcuts and advices.

There is a newer version: 6.0.1
Show newest version
// Copyright (c) 2003-2014, Jodd Team (jodd.org). All Rights Reserved.

package jodd.methref;

import jodd.proxetta.ProxyAdvice;
import jodd.proxetta.ProxyTarget;

import static jodd.proxetta.ProxyTarget.returnType;
import static jodd.proxetta.ProxyTarget.targetMethodName;

/**
 * Methref advice applied on all methods. It puts method name in
 * class variable that can be accessed later using reflection.
 */
public class MethrefAdvice implements ProxyAdvice {

	String methodName;

	/**
	 * Reads method name and stores it in local variable.
	 * For methods that return String returns the method name,
	 * otherwise returns null.
	 */
	public Object execute() {
		methodName = targetMethodName();

		Class returnType = returnType();

		if (returnType == String.class) {
			return ProxyTarget.returnValue(targetMethodName());
		}
		return ProxyTarget.returnValue(null);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy