Java Code Examples for javax.lang.model.type.TypeKind#values()

The following examples show how to use javax.lang.model.type.TypeKind#values() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestTypeKind.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static int testIsPrimitive() {
    int failures = 0;
    // The eight primitive types
    Set<TypeKind> primitives = EnumSet.of(BOOLEAN,  // 1
                                          BYTE,     // 2
                                          CHAR,     // 3
                                          DOUBLE,   // 4
                                          FLOAT,    // 5
                                          INT,      // 6
                                          LONG,     // 7
                                          SHORT);   // 8

    for(TypeKind tk : TypeKind.values()) {
        boolean primitiveness;
        if ((primitiveness=tk.isPrimitive()) != primitives.contains(tk) ) {
            failures++;
            System.err.println("Unexpected isPrimitive value " + primitiveness +
                               "for " + tk);
        }
    }
    return failures;
}
 
Example 2
Source File: TestTypeKind.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static int testIsPrimitive() {
    int failures = 0;
    // The eight primitive types
    Set<TypeKind> primitives = EnumSet.of(BOOLEAN,  // 1
                                          BYTE,     // 2
                                          CHAR,     // 3
                                          DOUBLE,   // 4
                                          FLOAT,    // 5
                                          INT,      // 6
                                          LONG,     // 7
                                          SHORT);   // 8

    for(TypeKind tk : TypeKind.values()) {
        boolean primitiveness;
        if ((primitiveness=tk.isPrimitive()) != primitives.contains(tk) ) {
            failures++;
            System.err.println("Unexpected isPrimitive value " + primitiveness +
                               "for " + tk);
        }
    }
    return failures;
}
 
Example 3
Source File: TestTypeKind.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static int testIsPrimitive() {
    int failures = 0;
    // The eight primitive types
    Set<TypeKind> primitives = EnumSet.of(BOOLEAN,  // 1
                                          BYTE,     // 2
                                          CHAR,     // 3
                                          DOUBLE,   // 4
                                          FLOAT,    // 5
                                          INT,      // 6
                                          LONG,     // 7
                                          SHORT);   // 8

    for(TypeKind tk : TypeKind.values()) {
        boolean primitiveness;
        if ((primitiveness=tk.isPrimitive()) != primitives.contains(tk) ) {
            failures++;
            System.err.println("Unexpected isPrimitive value " + primitiveness +
                               "for " + tk);
        }
    }
    return failures;
}
 
Example 4
Source File: SourceModeler.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Collection<TypeMirror> getBoxedPrimitives( 
        CompilationController controller)
{
    TypeKind[] values = TypeKind.values();
    Collection<TypeMirror> result = new ArrayList<TypeMirror>( values.length);
    for (TypeKind typeKind : values) {
        if ( typeKind.isPrimitive() ){
            PrimitiveType primitiveType = 
                controller.getTypes().getPrimitiveType(typeKind);
            TypeElement boxedClass = controller.getTypes().
                boxedClass(primitiveType);
            result.add( boxedClass.asType() );
        }
    }
    return result;
}
 
Example 5
Source File: TestTypeKind.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
static int testIsPrimitive() {
    int failures = 0;
    // The eight primitive types
    Set<TypeKind> primitives = EnumSet.of(BOOLEAN,  // 1
                                          BYTE,     // 2
                                          CHAR,     // 3
                                          DOUBLE,   // 4
                                          FLOAT,    // 5
                                          INT,      // 6
                                          LONG,     // 7
                                          SHORT);   // 8

    for(TypeKind tk : TypeKind.values()) {
        boolean primitiveness;
        if ((primitiveness=tk.isPrimitive()) != primitives.contains(tk) ) {
            failures++;
            System.err.println("Unexpected isPrimitive value " + primitiveness +
                               "for " + tk);
        }
    }
    return failures;
}
 
Example 6
Source File: TestTypeKind.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static int testIsPrimitive() {
    int failures = 0;
    // The eight primitive types
    Set<TypeKind> primitives = EnumSet.of(BOOLEAN,  // 1
                                          BYTE,     // 2
                                          CHAR,     // 3
                                          DOUBLE,   // 4
                                          FLOAT,    // 5
                                          INT,      // 6
                                          LONG,     // 7
                                          SHORT);   // 8

    for(TypeKind tk : TypeKind.values()) {
        boolean primitiveness;
        if ((primitiveness=tk.isPrimitive()) != primitives.contains(tk) ) {
            failures++;
            System.err.println("Unexpected isPrimitive value " + primitiveness +
                               "for " + tk);
        }
    }
    return failures;
}
 
Example 7
Source File: TestTypeKind.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static int testIsPrimitive() {
    int failures = 0;
    // The eight primitive types
    Set<TypeKind> primitives = EnumSet.of(BOOLEAN,  // 1
                                          BYTE,     // 2
                                          CHAR,     // 3
                                          DOUBLE,   // 4
                                          FLOAT,    // 5
                                          INT,      // 6
                                          LONG,     // 7
                                          SHORT);   // 8

    for(TypeKind tk : TypeKind.values()) {
        boolean primitiveness;
        if ((primitiveness=tk.isPrimitive()) != primitives.contains(tk) ) {
            failures++;
            System.err.println("Unexpected isPrimitive value " + primitiveness +
                               "for " + tk);
        }
    }
    return failures;
}
 
Example 8
Source File: TestTypeKind.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
static int testIsPrimitive() {
    int failures = 0;
    // The eight primitive types
    Set<TypeKind> primitives = EnumSet.of(BOOLEAN,  // 1
                                          BYTE,     // 2
                                          CHAR,     // 3
                                          DOUBLE,   // 4
                                          FLOAT,    // 5
                                          INT,      // 6
                                          LONG,     // 7
                                          SHORT);   // 8

    for(TypeKind tk : TypeKind.values()) {
        boolean primitiveness;
        if ((primitiveness=tk.isPrimitive()) != primitives.contains(tk) ) {
            failures++;
            System.err.println("Unexpected isPrimitive value " + primitiveness +
                               "for " + tk);
        }
    }
    return failures;
}
 
Example 9
Source File: TestTypeKind.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
static int testIsPrimitive() {
    int failures = 0;
    // The eight primitive types
    Set<TypeKind> primitives = EnumSet.of(BOOLEAN,  // 1
                                          BYTE,     // 2
                                          CHAR,     // 3
                                          DOUBLE,   // 4
                                          FLOAT,    // 5
                                          INT,      // 6
                                          LONG,     // 7
                                          SHORT);   // 8

    for(TypeKind tk : TypeKind.values()) {
        boolean primitiveness;
        if ((primitiveness=tk.isPrimitive()) != primitives.contains(tk) ) {
            failures++;
            System.err.println("Unexpected isPrimitive value " + primitiveness +
                               "for " + tk);
        }
    }
    return failures;
}
 
Example 10
Source File: TurbineTypesFactoryTest.java    From turbine with Apache License 2.0 5 votes vote down vote up
@Test
public void primitiveTypes() {
  for (TypeKind kind : TypeKind.values()) {
    if (kind.isPrimitive()) {
      PrimitiveType type = turbineTypes.getPrimitiveType(kind);
      assertThat(type.getKind()).isEqualTo(kind);
    } else {
      try {
        turbineTypes.getPrimitiveType(kind);
        fail();
      } catch (IllegalArgumentException expected) {
      }
    }
  }
}
 
Example 11
Source File: TurbineTypeMirrorTest.java    From turbine with Apache License 2.0 5 votes vote down vote up
@Test
public void primitiveTypes() {
  for (TypeKind kind : TypeKind.values()) {
    if (!kind.isPrimitive()) {
      continue;
    }
    TurbineConstantTypeKind turbineKind = TurbineConstantTypeKind.valueOf(kind.name());
    TypeMirror type = factory.asTypeMirror(PrimTy.create(turbineKind, ImmutableList.of()));
    assertThat(type.getKind()).isEqualTo(kind);
  }
}
 
Example 12
Source File: TreeBackedTypesTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void testIsSameTypePrimitiveType() throws IOException {
  initCompiler();

  for (TypeKind typeKind : TypeKind.values()) {
    if (typeKind.isPrimitive()) {
      PrimitiveType primitiveType = types.getPrimitiveType(typeKind);
      PrimitiveType primitiveType2 = types.getPrimitiveType(typeKind);

      assertSameType(primitiveType, primitiveType2);
    }
  }
}
 
Example 13
Source File: Imports.java    From immutables with Apache License 2.0 5 votes vote down vote up
private void collectBuiltins(Map<String, TypeMirror> collected) {
  for (TypeKind kind : TypeKind.values()) {
    if (kind.isPrimitive()) {
      TypeElement boxedClass = types.boxedClass(types.getPrimitiveType(kind));
      collected.put(boxedClass.getSimpleName().toString(), boxedClass.asType());
    }
  }

  TypeElement typeElement = elements.getTypeElement(String.class.getCanonicalName());
  collected.put(typeElement.getSimpleName().toString(), typeElement.asType());

  typeElement = elements.getTypeElement(Templates.Invokable.class.getCanonicalName());
  collected.put(typeElement.getSimpleName().toString(), typeElement.asType());
}