Package com.sun.mirror.type

Examples of com.sun.mirror.type.TypeMirror


    }
    return result_param;
  }

  public static TypeMirror getMethodReturnType(MethodDeclaration method) {
    TypeMirror result_type;
    ParameterDeclaration result_param = getResultParameter(method);
    if (result_param != null) {
      result_type = result_param.getType();
    } else
      result_type = method.getReturnType();
View Full Code Here


         || !modifiers.contains(Modifier.FINAL) ) {
      throw new RuntimeException("Field " + field.getSimpleName() + " is not declared public static final");
    }

    // Check suported types (int, long, float, String)
    TypeMirror field_type = field.getType();
    if ( field_type instanceof PrimitiveType ) {
      PrimitiveType field_type_prim = (PrimitiveType)field_type;
      PrimitiveType.Kind field_kind = field_type_prim.getKind();
      if ( field_kind != PrimitiveType.Kind.INT
           && field_kind != PrimitiveType.Kind.LONG
           && field_kind != PrimitiveType.Kind.FLOAT ) {
        throw new RuntimeException("Field " + field.getSimpleName() + " is not of type 'int', 'long' or 'float'");
      }
    } else if ( "java.lang.String".equals(field_type.toString()) ) {
    } else {
      throw new RuntimeException("Field " + field.getSimpleName() + " is not a primitive type or String");
    }

    Object field_value = field.getConstantValue();
View Full Code Here

    }
    return result_param;
  }

  public static TypeMirror getMethodReturnType(MethodDeclaration method) {
    TypeMirror result_type;
    ParameterDeclaration result_param = getResultParameter(method);
    if ( result_param != null ) {
      result_type = result_param.getType();
    } else
      result_type = method.getReturnType();
View Full Code Here

         || !modifiers.contains(Modifier.FINAL) ) {
      throw new RuntimeException("Field " + field.getSimpleName() + " is not declared public static final");
    }

    // Check suported types (int, long, float, String)
    TypeMirror field_type = field.getType();
    if ( field_type instanceof PrimitiveType ) {
      PrimitiveType field_type_prim = (PrimitiveType)field_type;
      PrimitiveType.Kind field_kind = field_type_prim.getKind();
      if ( field_kind != PrimitiveType.Kind.INT
           && field_kind != PrimitiveType.Kind.LONG
           && field_kind != PrimitiveType.Kind.FLOAT
           && field_kind != PrimitiveType.Kind.BYTE ) {
        throw new RuntimeException("Field " + field.getSimpleName() + " is not of type 'int', 'long' or 'float'");
      }
    } else if ( "java.lang.String".equals(field_type.toString()) ) {
    } else {
      throw new RuntimeException("Field " + field.getSimpleName() + " is not a primitive type or String");
    }

    Object field_value = field.getConstantValue();
View Full Code Here

            return dataType;
        }

        @Override
        public void visitArrayType(final ArrayType arrayType) {
            final TypeMirror componentType = arrayType.getComponentType();
            componentType.accept(new SimpleTypeVisitor() {

                @Override
                public void visitPrimitiveType(PrimitiveType primitiveType) {
                    Kind kind = primitiveType.getKind();
                    if (kind == Kind.BYTE) {
View Full Code Here

                    MessageCode.SLIM3GEN1004,
                    env,
                    declaration.getPosition(),
                    declaredType);
            }
            TypeMirror elementType = typeArgs.iterator().next();
            DeclaredType elementDeclaredType =
                TypeUtil.toDeclaredType(elementType);
            if (elementDeclaredType == null) {
                throw new ValidationException(
                    MessageCode.SLIM3GEN1016,
View Full Code Here

        if (!methodName.startsWith("set")
            || !TypeUtil.isVoid(m.getReturnType())
            || m.getParameters().size() != 1) {
            return false;
        }
        TypeMirror parameterTypeMirror =
            m.getParameters().iterator().next().getType();
        if (!parameterTypeMirror.equals(fieldDeclaration.getType())) {
            return false;
        }
        return methodName.equals(FieldDeclarationUtil
            .getWriteMethodName(fieldDeclaration));
    }
View Full Code Here

    Collection<ParameterDeclaration> parameters = e.getParameters();
    for ( ParameterDeclaration param : parameters ) {
      if ( !isFirstParam ) {
        methodCode.append( ", " );
      }
      TypeMirror paramType = param.getType();

      methodCode.append( paramType.toString() );
      methodCode.append( " " );
      String paramName = param.toString();
      // For some reason, the name is "int myVar" if it's a primative type
      // Get rid of the "int" bit.
      if ( paramName.contains( " " ) ) {
View Full Code Here

    Collection<ParameterDeclaration> parameters = e.getParameters();
    for ( ParameterDeclaration param : parameters ) {
      if ( !isFirstParam ) {
        methodCode.append( ", " );
      }
      TypeMirror paramType = param.getType();

      methodCode.append( paramType.toString() );
      methodCode.append( " " );
      String paramName = param.toString();
      // For some reason, the name is "int myVar" if it's a primative type
      // Get rid of the "int" bit.
      if ( paramName.contains( " " ) ) {
View Full Code Here

    protected String getClassNameOfClassParameter(
            AnnotationTypeElementDeclaration declaration, AnnotationValue value){
        String className = TypeUtil.toClassType(
            (TypeMirror)declaration.getDefaultValue().getValue()
            ).getDeclaration().getQualifiedName();
        TypeMirror mirror = (TypeMirror)value.getValue();
        if(mirror == null){
            return className;
        }
        if (value instanceof InterfaceType) {
            throw new ValidationException(
View Full Code Here

TOP

Related Classes of com.sun.mirror.type.TypeMirror

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.