PrimitiveType — 프리미티브 타입 인터페이스

PrimitiveType — 프리미티브 타입 인터페이스

PrimitiveType는 프리미티브 타입(primitive type)을 나타내는 인터페이스예요. 여기에는 boolean, byte, short, int, long, char, float, double이 포함돼요.

자바 언어 명세 4.2(Primitive Types and Values) 참고. TypeMirror를 확장해요.

출처: Java API Reference

본문

선언은 다음과 같아요.

public interface PrimitiveType extends TypeMirror

이 인터페이스는 자체 메서드를 선언하지 않아요. TypeMirroraccept, getKind, getAnnotation, toString 등을 상속해요.

getKind()TypeKind.BOOLEAN, BYTE, SHORT, INT, LONG, CHAR, FLOAT, DOUBLE 중 하나를 반환하면 그 타입이 프리미티브 타입이에요. TypeKind.isPrimitive()도 같은 판별을 도와줘요. 프리미티브 타입 객체를 얻으려면 Types.getPrimitiveType(TypeKind)을 써요.

TypeMirror t = ...;
if (t.getKind().isPrimitive()) {
    // 프리미티브 타입
}

Since: 1.6.

더 알아보기 (Learn more)

Java 공식 API