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

spoon.examples.stack.processing.BoundProcessor Maven / Gradle / Ivy

The newest version!
package spoon.examples.stack.processing;

import spoon.examples.stack.annotation.Bound;
import spoon.examples.stack.template.BoundTestTemplate;
import spoon.processing.AbstractAnnotationProcessor;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtMethod;

/**
 * This processor (see the code below) processes the
 * {@link spoon.examples.stack.annotation.Bound} annotation and uses
 * {@link spoon.examples.stack.template.BoundTestTemplate} to insert a test on
 * the bound in the push method.
 */
public class BoundProcessor extends
		AbstractAnnotationProcessor> {
	public void process(Bound b, CtClass c) {
		CtMethod push = c.getMethod("push", getFactory().Type()
				.createTypeParameterReference("T"));
		BoundTestTemplate template = new BoundTestTemplate(b.max());
		push.getBody().insertBegin(template.getSubstitution(c));
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy