NullType — null 타입 인터페이스
NullType — null 타입 인터페이스
NullType는 null 타입을 나타내는 인터페이스예요. 이는 표현식 null의 타입이에요. ReferenceType와 TypeMirror를 확장해요.
자바에서 null 리터럴은 고유한 타입을 가지며, 이 타입은 참조 타입에 할당될 수 있어요. 자바 언어 명세 3.10.7(The Null Literal)과 4.1(The Kinds of Types and Values) 참고.
본문
선언은 다음과 같아요.
public interface NullType extends ReferenceType
이 인터페이스는 자체 메서드를 선언하지 않아요. TypeMirror의 accept, getKind, getAnnotation, toString 등을 상속해요.
getKind()가 TypeKind.NULL을 반환하면 그 타입이 null 타입이에요. null 타입 객체를 얻으려면 Types.getNullType()을 써요. 예를 들어 어떤 타입이 null 타입인지 판별하려면:
TypeMirror tm = ...;
if (tm.getKind() == TypeKind.NULL) {
// null 타입
}
Since: 1.6.