Search in sources :

Example 1 with Parameter

use of spoon.template.Parameter in project spoon by INRIA.

the class Parameters method getParameterName.

private static String getParameterName(Field f) {
    String name = f.getName();
    Parameter p = f.getAnnotation(Parameter.class);
    if ((p != null) && !p.value().equals("")) {
        name = p.value();
    }
    return name;
}
Also used : TemplateParameter(spoon.template.TemplateParameter) Parameter(spoon.template.Parameter)

Example 2 with Parameter

use of spoon.template.Parameter in project spoon by INRIA.

the class Parameters method getParameterField.

public static CtField<?> getParameterField(CtClass<? extends Template<?>> templateClass, String parameterName) {
    for (CtTypeMember typeMember : templateClass.getTypeMembers()) {
        if (!(typeMember instanceof CtField)) {
            continue;
        }
        CtField<?> f = (CtField<?>) typeMember;
        Parameter p = f.getAnnotation(Parameter.class);
        if (p == null) {
            continue;
        }
        if (f.getSimpleName().equals(parameterName)) {
            return f;
        }
        if (parameterName.equals(p.value())) {
            return f;
        }
    }
    return null;
}
Also used : CtTypeMember(spoon.reflect.declaration.CtTypeMember) CtField(spoon.reflect.declaration.CtField) TemplateParameter(spoon.template.TemplateParameter) Parameter(spoon.template.Parameter)

Example 3 with Parameter

use of spoon.template.Parameter in project spoon by INRIA.

the class Parameters method getParameterName.

private static String getParameterName(CtFieldReference<?> f) {
    String name = f.getSimpleName();
    Parameter p = f.getDeclaration().getAnnotation(Parameter.class);
    if ((p != null) && !p.value().equals("")) {
        name = p.value();
    }
    return name;
}
Also used : TemplateParameter(spoon.template.TemplateParameter) Parameter(spoon.template.Parameter)

Aggregations

Parameter (spoon.template.Parameter)3 TemplateParameter (spoon.template.TemplateParameter)3 CtField (spoon.reflect.declaration.CtField)1 CtTypeMember (spoon.reflect.declaration.CtTypeMember)1