use of javax.lang.model.type.TypeMirror in project neo4j by neo4j.
the class AllowedTypesValidator method isValidErasedType.
private boolean isValidErasedType(TypeMirror actualType) {
return whitelistedTypes.stream().anyMatch(type -> {
TypeMirror erasedAllowedType = typeUtils.erasure(type);
TypeMirror map = typeUtils.erasure(typeMirrors.typeMirror(Map.class));
TypeMirror list = typeUtils.erasure(typeMirrors.typeMirror(List.class));
if (typeUtils.isSameType(erasedAllowedType, map) || typeUtils.isSameType(erasedAllowedType, list)) {
return typeUtils.isSubtype(actualType, erasedAllowedType);
}
return typeUtils.isSameType(actualType, erasedAllowedType);
});
}
use of javax.lang.model.type.TypeMirror in project neo4j by neo4j.
the class RecordTypeVisitorTest method validates_supported_record.
@Test
public void validates_supported_record() throws Exception {
TypeMirror recordStreamType = typeMirrorTestUtils.typeOf(Stream.class, ValidRecord.class);
assertThat(visitor.visit(recordStreamType)).isEmpty();
}
use of javax.lang.model.type.TypeMirror in project neo4j by neo4j.
the class RecordTypeVisitorTest method does_not_validate_record_with_nonpublic_fields.
@Test
public void does_not_validate_record_with_nonpublic_fields() throws Exception {
TypeMirror recordStreamType = typeMirrorTestUtils.typeOf(Stream.class, InvalidRecord.class);
assertThat(visitor.visit(recordStreamType)).hasSize(1).extracting(CompilationMessage::getCategory, CompilationMessage::getContents).containsExactly(tuple(Diagnostic.Kind.ERROR, "Record definition error: field InvalidRecord#foo must" + " be public"));
}
use of javax.lang.model.type.TypeMirror in project storio by pushtorefresh.
the class JavaTypeTest method fromBoolean.
@Test
public void fromBoolean() {
final TypeMirror typeMirror = mockTypeMirror(TypeKind.BOOLEAN, null);
assertThat(JavaType.from(typeMirror)).isEqualTo(BOOLEAN);
}
use of javax.lang.model.type.TypeMirror in project storio by pushtorefresh.
the class JavaTypeTest method fromLong.
@Test
public void fromLong() {
final TypeMirror typeMirror = mockTypeMirror(TypeKind.LONG, null);
assertThat(JavaType.from(typeMirror)).isEqualTo(LONG);
}
Aggregations