ReferenceType — 참조 타입 인터페이스
ReferenceType — 참조 타입 인터페이스
ReferenceType는 참조 타입(reference type)을 나타내는 인터페이스예요. 여기에는 클래스·인터페이스 타입, 배열 타입, 타입 변수, 그리고 null 타입이 포함돼요.
자바 언어 명세 4.3(Reference Types and Values) 참고. TypeMirror를 확장해요.
본문
선언은 다음과 같아요.
public interface ReferenceType extends TypeMirror
하위 인터페이스로는 ArrayType, DeclaredType, ErrorType, NullType, TypeVariable이 있어요. 이 인터페이스는 자체 메서드를 선언하지 않아요.
// 참조 타입인지 판별하려면:
TypeMirror t = ...;
if (t instanceof ReferenceType) {
// 참조 타입 (클래스·배열·타입 변수·null)
}
단, 일반적으로는 instanceof보다 getKind()와 방문자(visitor)를 쓰는 게 이 모델링 계층에서 더 신뢰할 만해요. Since: 1.6.