Exemplo n.º 1
0
  /**
   * Build a new field model based on the name and Java type
   *
   * @param fieldName the name of the field
   * @param type the Java raw type that will allow further analyzes
   */
  public FieldAttributeModel(String fieldName, Type type) {
    this.fieldName = fieldName;
    this.type = type;
    this.typeName = convertType(type);

    if (typeName.startsWith("Array<") || typeName.startsWith("Map<")) {
      this.needInitialize = true;
    }

    if (this.type instanceof ParameterizedType) {
      ParameterizedType parameterizedType = (ParameterizedType) this.type;
      Type rawType = parameterizedType.getRawType();
      analyzeParametrizedType(parameterizedType, rawType);
    } else if (Primitives.isPrimitive(this.type)
        || Primitives.isWrapperType(this.type)
        || String.class.equals(this.type)) {
      this.isPrimitive = true;
    } else if (this.type instanceof Class && ((Class) this.type).isAnnotationPresent(DTO.class)) {
      this.isDto = true;
      dtoImpl = this.type.getTypeName() + "Impl";
    }
  }