RecordComponentElement — 레코드 컴포넌트 요소 인터페이스
RecordComponentElement — 레코드 컴포넌트 요소 인터페이스
RecordComponentElement는 레코드 컴포넌트(record component)를 나타내는 인터페이스예요. 레코드 컴포넌트란 레코드 헤더에 선언된 각 구성 요소(이름·타입)를 뜻해요.
레코드 헤더 record Point(int x, int y)에서 x와 y가 각각 하나의 레코드 컴포넌트예요. 각 컴포넌트는 필드·접근자(accessor)·생성자 매개변수와 연결돼요. 자바 언어 명세 8.10.1(Record Components) 참고.
본문
선언은 다음과 같아요.
public interface RecordComponentElement extends Element
주요 메서드는 다음과 같아요.
| Modifier and Type | Method | 설명 |
|---|---|---|
ExecutableElement |
getAccessor() |
주어진 레코드 컴포넌트와 연결된 접근자(accessor)의 실행 가능 요소를 반환해요. |
Element |
getEnclosingElement() |
이 레코드 컴포넌트를 포함하는 요소를 반환해요. |
Name |
getSimpleName() |
이 레코드 컴포넌트의 단순 이름을 반환해요. |
getAccessor()는 컴포넌트 이름과 같은 이름의 접근자 메서드(예:x())를 나타내는ExecutableElement를 돌려줘요.getEnclosingElement()은 레코드 클래스 자체(TypeElement)를 돌려줘요.
레코드 컴포넌트 목록은 TypeElement.getRecordComponents()로 얻을 수 있어요. Since: 16.