Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] simple question about matching lists

How about:

@Before("execution(public * *(List<VEHICLE+>, ..))  && args(firstArgument,..) ")
public void provideAdviseUponMethodInvocation( List<? extends VEHICLE>
 firstArgument , JoinPoint jp )

as shown in this example:
===
import java.util.List;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;


public aspect Test {
	public void planes(List<Plane> planes) {	} // does not match
	public void cars(List<Car> cars) {	} // matches
	public void buses(List<Bus> buses) {	} // matches
}

@Aspect
class Azpect {
	@Before("execution(public * *(List<Vehicle+>, ..))  &&
args(firstArgument,..) ")
	public void provideAdviseUponMethodInvocation( List<? extends
Vehicle>  firstArgument , JoinPoint jp ) {
	}
}
	
class Vehicle {}
class Car extends Vehicle {}
class Bus extends Vehicle {}
class Plane {}
===

Andy

On 26 April 2011 15:29, Srinivas S Tamvada <tssrinivas@xxxxxxxxx> wrote:
> Hi
> I am trying to match methods which take list arguments.
> I am interested only in list of "vehicles" or subtypes.
>
> Below does not seem to match. Any comments will be appreciated.
> Seems okay according to http://www.eclipse.org/aspectj/doc/released/adk15notebook/generics-inAspectJ5.html.
>
>
>
> Thanks,
> -SST
>
> @Before("execution(public * *(List<VEHICLE+>, ..))  && args(firstArgument,..) ")
>    public void provideAdviseUponMethodInvocation( List<VEHICLE>  firstArgument , JoinPoint jp )
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top