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

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

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

import spoon.examples.bound.annotation.Bound;
import spoon.examples.bound.template.BoundTemplate;
import spoon.processing.AbstractAnnotationProcessor;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtExecutable;
import spoon.reflect.declaration.CtParameter;
import spoon.template.Substitution;
import spoon.template.Template;

public class BoundProcessor extends
		AbstractAnnotationProcessor> {

	public void process(Bound annotation, CtParameter element) {
		CtExecutable e = element.getParent();
		if (e.getBody() == null)
			return;
		if (!(e.getDeclaringType() instanceof CtClass)) {
			return;
		}
		CtClass type = (CtClass) e.getDeclaringType();
		Template t = new BoundTemplate(element.getSimpleName(), annotation
				.min(), annotation.max());
		e.getBody().insertBegin(
				Substitution.substituteMethodBody(type, t, "test", getFactory()
						.Type().createReference(Double.class)));
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy