Java 类org.apache.maven.plugins.annotations.Parameter 实例源码

项目:takari-lifecycle    文件:MojoDescriptorGleaner.java   
private void processTypeFields(TypeElement type, MojoDescriptor descriptor) {
  // non-static fields
  for (Element member : type.getEnclosedElements()) {
    if (member instanceof VariableElement) {
      Parameter parameter = member.getAnnotation(Parameter.class);
      Component component = member.getAnnotation(Component.class);
      if (parameter != null && component != null) {
        // TODO error marker
      }
      if (parameter != null) {
        descriptor.addParameter(toParameterDescriptor((VariableElement) member, parameter));
      } else if (component != null) {
        descriptor.addRequirement(toComponentDescriptor((VariableElement) member, component));
      }
    }
  }
}
项目:takari-lifecycle    文件:MojoDescriptorGleaner.java   
private MojoParameter toParameterDescriptor(VariableElement field, Parameter parameter) {
  MojoParameter result = new MojoParameter();
  result.setName(field.getSimpleName().toString());
  if (!isEmpty(parameter.alias())) {
    result.setAlias(parameter.alias());
  }
  if (!isEmpty(parameter.defaultValue())) {
    result.setDefaultValue(parameter.defaultValue());
  }
  if (!isEmpty(parameter.property())) {
    result.setExpression("${" + parameter.property() + "}");
  }
  result.setEditable(!parameter.readonly());
  result.setRequired(parameter.required());
  result.setType(getTypeString(field.asType()));
  result.setDescription(getDescription(field));

  return result;
}
项目:takari-lifecycle    文件:MojoDescriptorGleaner.java   
private Set<TypeElement> getAnnotatedTypes(RoundEnvironment roundEnv) {
  Set<TypeElement> types = new HashSet<>();
  roundEnv.getElementsAnnotatedWith(Mojo.class).forEach(type -> types.add((TypeElement) type));
  addAnnotatedMembers(types, roundEnv, Parameter.class);
  addAnnotatedMembers(types, roundEnv, Component.class);
  return types;
}
项目:takari-lifecycle    文件:MojoDescriptorGleaner.java   
@Override
public Set<String> getSupportedAnnotationTypes() {
  Set<String> types = new HashSet<>();
  types.add(Mojo.class.getName());
  types.add(Parameter.class.getName());
  types.add(Component.class.getName());
  return types;
}