Это дополнительный вопрос Как получить класс аннотации из TypeDescription
Я пытаюсь сгенерировать методы, используя Plugin
.
С данным классом, таким как.
class {
@Func
T some;
}
Я нашел поле со специальной аннотацией.
И я прошу помощи в создании метода, похожего на этот.
public <R> R applySome(Function<T, R> function) {
return function.apply(some);
}
Как я могу сделать метод в
@Override
public DynamicType.Builder<?> apply(final DynamicType.Builder<?> builder, final TypeDescription typeDescription,
final ClassFileLocator classFileLocator) {
System.out.printf("apply(%1$s, %2$s, %3$s)\n", builder, typeDescription, classFileLocator);
final List<FieldDescription.InDefinedShape> fields = fields(typeDescription);
fields.forEach(field -> {
System.out.printf("\tfield: %1$s\n", field);
System.out.printf("\tfield.name: %1$s\n", field.getName());
System.out.printf("\tfield.type: %1$s\n", field.getType());
System.out.printf("\tfield.declaringType: %1$s\n", field.getDeclaringType());
// define the method.
});
return null;
}