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

spoon.template.Template Maven / Gradle / Ivy

/* 
 * Spoon - http://spoon.gforge.inria.fr/
 * Copyright (C) 2006 INRIA Futurs 
 * 
 * This software is governed by the CeCILL-C License under French law and
 * abiding by the rules of distribution of free software. You can use, modify 
 * and/or redistribute the software under the terms of the CeCILL-C license as 
 * circulated by CEA, CNRS and INRIA at http://www.cecill.info. 
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
 * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
 *  
 * The fact that you are presently reading this means that you have had
 * knowledge of the CeCILL-C license and that you accept its terms.
 */

package spoon.template;

import spoon.reflect.declaration.CtType;

/**
 * This maker interface should be implemented by the classes containing some
 * template code, so that they can be used as template parameter values holder
 * for the {@link Substitution} methods.
 * 
 * 

* A template code is simply a piece of code that uses a * {@link TemplateParameter}'s instance. It must then invoke the * {@link TemplateParameter#S()} method. * *

* When the template parameter is a String or a primitive type (or a boxing * type) representing a literal, or a Class, the template parameter can be * directly accessed. * *

 *       import spoon.template.Template;
 *       import spoon.template.Value;
 *       
 *       public class SimpleTemplate implements Template {
 *           // template parameter fields 
 *            \@Parameter String _parameter_;
 *       
 *           // parameters binding
 *            \@Local
 *           public SimpleTemplate(String parameter) {
 *               _parameter_ = parameter;
 *           }
 *       
 *           // template method
 *           public void simpleTemplateMethod() {
 *               System.out.println(_parameter_);
 *           }
 *       }
 * 
* *

* The template parameters must be bound to their values in the template's * constructor (which should be defined as a template's * {@link spoon.template.Local}. A possible use of a template would be to * insert the template into a target class, by using * {@link Substitution#insertAll(CtType,Template)}: * *

 *       spoon.reflect.CtClass target=...;
 *       Template template=new SimpleTemplate("hello templated world");
 *       Substitution.insertAll(target,template);
 * 
* *

* If the target class is an empty class named A, the resulting * code will be: * *

 * public class A {
 * 	public void insertedMethod() {
 * 		System.out.println("hello templated world");
 * 	}
 * }
 * 
* */ public interface Template { }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy