コード例 #1
0
  private IMethodModel processMethod(CtMethod<?> m, TypeModel ownerType) {

    MethodModel methodModel = new MethodModel();
    fillBasic(methodModel, m);
    fillTypeParameters(methodModel, m);
    CtTypeReference<?> returnedType = m.getType();
    ITypeModel returnedTypeModel = processTypeReference(returnedType);
    methodModel.setReturnedType(returnedTypeModel);
    fillJAXBType(methodModel, returnedType);

    List<CtParameter<?>> parameters = m.getParameters();
    for (CtParameter<?> p : parameters) {
      IParameterModel parameterModel = processParameter(p);
      methodModel.addParameter(parameterModel);
    }
    String returnedTypeSimpleName = returnedType.getSimpleName();
    String returnedTypeQualifiedname = returnedType.getQualifiedName();
    if (returnedTypeSimpleName.equalsIgnoreCase(returnedTypeQualifiedname)) {
      for (ITypeParameter tp : ownerType.getTypeParameters()) {
        if (returnedType.getSimpleName().equals(tp.getName())) {
          methodModel.setHasGenericReturnType(true);
        }
      }
      for (ITypeParameter tp : methodModel.getTypeParameters()) {
        if (returnedType.getSimpleName().equals(tp.getName())) {
          methodModel.setHasGenericReturnType(true);
        }
      }
    }
    return methodModel;
  }
コード例 #2
0
  private IFieldModel processField(CtField<?> m, TypeModel ownerType) {
    FieldModel fm = new FieldModel();
    fillBasic(fm, m);
    CtTypeReference<?> type = m.getType();
    fillJAXBType(fm, type);

    String typeSimpleName = type.getSimpleName();
    String typeQualifiedname = type.getQualifiedName();
    if (typeSimpleName.equalsIgnoreCase(typeQualifiedname)) {
      for (ITypeParameter tp : ownerType.getTypeParameters()) {
        if (typeSimpleName.equals(tp.getName())) {
          fm.setGeneric(true);
        }
      }
    }
    return fm;
  }