Class Parameters

java.lang.Object
spoon.support.template.Parameters

public abstract class Parameters extends Object
This class defines an API to manipulate template parameters.
  • Field Details

    • fieldPrefix

      protected static final String fieldPrefix
      The prefix "_FIELD_" for a parameter that represents a fields in order to avoid name clashes.
      See Also:
      Constant Field Values
  • Method Details

    • getIndex

      public static Integer getIndex(CtExpression<?> e)
      Gets the index of a one-dimension array (helper).
    • getValue

      public static Object getValue(Template<?> template, String parameterName, Integer index)
      Gets a template field parameter value.
    • getParameterField

      public static CtField<?> getParameterField(CtClass<? extends Template<?>> templateClass, String parameterName)
    • setValue

      public static void setValue(Template<?> template, String parameterName, Integer index, Object value)
      Sets a template field parameter value.
    • getNames

      public static List<String> getNames(CtClass<? extends Template<?>> templateType)
      Gets the names of all the template parameters of a given template type (including the ones defined by the super types).
    • getNamesToValues

      public static Map<String,​Object> getNamesToValues(Template<?> template, CtClass<? extends Template<?>> templateType)
      Gets the Map of names to template parameter value for all the template parameters of a given template type (including the ones defined by the super types).
    • getTemplateParametersAsMap

      public static Map<String,​Object> getTemplateParametersAsMap(Factory f, Template<?> template)
      Gets the Map of names to template parameter values for all the template parameters of a given template type + adds mapping of template model reference to target type as parameter too
      Parameters:
      f - the factory
      targetType - the target type of the substitution (can be null), which will be done with result parameters
      template - the template that holds the parameter values
    • isParameterSource

      public static boolean isParameterSource(CtFieldReference<?> ref)
      Tells if a given field is a template parameter.
    • isParameterSource

      public static boolean isParameterSource(Field field)
      Tells if a given field is a template parameter.
    • getAllTemplateParameterFields

      public static List<Field> getAllTemplateParameterFields(Class<? extends Template> clazz)
      returns all the runtime fields of a template representing a template parameter
    • getAllTemplateParameterFields

      public static List<CtField<?>> getAllTemplateParameterFields(Class<? extends Template<?>> clazz, Factory factory)
      returns all the compile_time fields of a template representing a template parameter