@Test
  public void isSubtypeOf() throws Exception {
    JavaSymbol.PackageJavaSymbol packageSymbol =
        new JavaSymbol.PackageJavaSymbol("org.foo.bar", null);
    JavaSymbol.TypeJavaSymbol typeSymbol =
        new JavaSymbol.TypeJavaSymbol(Flags.PUBLIC, "MyType", packageSymbol);
    JavaSymbol.TypeVariableJavaSymbol typeVariableSymbol =
        new JavaSymbol.TypeVariableJavaSymbol("T", typeSymbol);
    ClassJavaType classType = (ClassJavaType) typeSymbol.type;
    TypeVariableJavaType typeVariableType = (TypeVariableJavaType) typeVariableSymbol.type;
    ArrayJavaType arrayType = new ArrayJavaType(typeSymbol.type, symbols.arrayClass);
    typeVariableType.bounds = Lists.newArrayList(symbols.objectType);

    classType.supertype = symbols.objectType;
    classType.interfaces = Lists.newArrayList(symbols.cloneableType);
    assertThat(classType.isSubtypeOf("java.lang.Object")).isTrue();
    assertThat(classType.isSubtypeOf(symbols.objectType)).isTrue();

    assertThat(classType.isSubtypeOf("org.foo.bar.MyType")).isTrue();
    assertThat(classType.isSubtypeOf(typeSymbol.type)).isTrue();

    assertThat(classType.isSubtypeOf("java.lang.CharSequence")).isFalse();
    assertThat(classType.isSubtypeOf(symbols.stringType)).isFalse();

    assertThat(classType.isSubtypeOf("java.lang.Cloneable")).isTrue();
    assertThat(classType.isSubtypeOf(symbols.cloneableType)).isTrue();
    assertThat(new JavaType(JavaType.BYTE, null).isSubtypeOf("java.lang.Object")).isFalse();

    assertThat(arrayType.isSubtypeOf("org.foo.bar.MyType[]")).isTrue();
    assertThat(arrayType.isSubtypeOf(new ArrayJavaType(typeSymbol.type, symbols.arrayClass)))
        .isTrue();

    assertThat(arrayType.isSubtypeOf("org.foo.bar.MyType")).isFalse();
    assertThat(arrayType.isSubtypeOf(typeSymbol.type)).isFalse();

    assertThat(arrayType.isSubtypeOf("java.lang.Object[]")).isTrue();
    assertThat(arrayType.isSubtypeOf(new ArrayJavaType(symbols.objectType, symbols.arrayClass)))
        .isTrue();

    assertThat(arrayType.isSubtypeOf("java.lang.Object")).isTrue();
    assertThat(arrayType.isSubtypeOf(symbols.objectType)).isTrue();

    assertThat(symbols.nullType.isSubtypeOf(symbols.objectType)).isTrue();
    assertThat(symbols.nullType.isSubtypeOf("java.lang.Object")).isTrue();
    assertThat(symbols.objectType.isSubtypeOf(symbols.nullType)).isFalse();

    assertThat(symbols.nullType.isSubtypeOf(arrayType)).isTrue();
    assertThat(arrayType.isSubtypeOf(symbols.nullType)).isFalse();
    assertThat(symbols.nullType.isSubtypeOf(symbols.nullType)).isTrue();

    assertThat(arrayType.isSubtypeOf("org.foo.bar.SomeClass[]")).isFalse();

    assertThat(typeVariableType.isSubtypeOf("java.lang.Object")).isTrue();
    assertThat(typeVariableType.is("java.lang.Object")).isFalse();
    assertThat(typeVariableType.isSubtypeOf("java.lang.CharSequence")).isFalse();

    assertThat(Symbols.unknownType.is("java.lang.Object")).isFalse();
    assertThat(Symbols.unknownType.isSubtypeOf("java.lang.CharSequence")).isFalse();
    assertThat(Symbols.unknownType.isSubtypeOf(symbols.objectType)).isFalse();
  }
  @Test
  public void is_class_is_array() throws Exception {
    JavaSymbol.PackageJavaSymbol packageSymbol =
        new JavaSymbol.PackageJavaSymbol("org.foo.bar", null);
    JavaSymbol.TypeJavaSymbol typeSymbol =
        new JavaSymbol.TypeJavaSymbol(Flags.PUBLIC, "MyType", packageSymbol);
    ArrayJavaType arrayType = new ArrayJavaType(typeSymbol.type, symbols.arrayClass);

    assertThat(typeSymbol.type.isClass()).isTrue();
    assertThat(typeSymbol.type.isArray()).isFalse();
    assertThat(arrayType.isClass()).isFalse();
    assertThat(arrayType.isArray()).isTrue();
  }
 @Test
 public void type_is_fully_qualified_name() {
   JavaSymbol.PackageJavaSymbol packageSymbol =
       new JavaSymbol.PackageJavaSymbol("org.foo.bar", null);
   JavaSymbol.TypeJavaSymbol typeSymbol =
       new JavaSymbol.TypeJavaSymbol(Flags.PUBLIC, "MyType", packageSymbol);
   JavaSymbol.TypeJavaSymbol typeSymbol2 =
       new JavaSymbol.TypeJavaSymbol(Flags.PUBLIC, "MyType", symbols.rootPackage);
   ArrayJavaType arrayType = new ArrayJavaType(typeSymbol.type, symbols.arrayClass);
   ClassJavaType classType = (ClassJavaType) typeSymbol.type;
   classType.interfaces = Lists.newArrayList();
   assertThat(symbols.byteType.is("byte")).isTrue();
   assertThat(symbols.byteType.is("int")).isFalse();
   assertThat(classType.is("org.foo.bar.MyType")).isTrue();
   assertThat(typeSymbol2.type.is("MyType")).isTrue();
   assertThat(classType.is("org.foo.bar.SomeClass")).isFalse();
   assertThat(arrayType.is("org.foo.bar.MyType[]")).isTrue();
   assertThat(arrayType.is("org.foo.bar.MyType")).isFalse();
   assertThat(arrayType.is("org.foo.bar.SomeClass[]")).isFalse();
   assertThat(symbols.nullType.is("org.foo.bar.SomeClass")).isTrue();
   assertThat(symbols.unknownType.is("org.foo.bar.SomeClass")).isFalse();
 }