Name

cast — Converts a set of objects to a known type

Synopsis

cast [[arguments] | [classes] | [fields] | [methods]]

  • stateless

Description

Some expressions (such as annotated by) might return results of any type. This leads to a situation where you might know better than the BBQ parser what the result type of an expression is. The cast transform allows you to supply that knowledge back to the parser so you can add further processing to the expression without the parser complaining about type safety.

cast forces the objects in the set to be interpreted as the specified type; any objects that aren't convertible to that type are dropped from the set.

Example

The following query returns methods annotated by annotations with the class org.junit.After that do not call a method matching "finish."

not exists ( ~ "finish" methods called by calls from )
	  	        cast methods annotated by annotations with class "org.junit.After"

Note that without the cast transform, the calls from operator would produce a type mismatch error, since it can not be applied to object.

Applies to Type

object

Results in Type

The type specified by the argument

browse-by-query home antlersoft free software sourceforge project page