23-03-14
안녕하세요. JetBrains 한국 총판 단군소프트입니다. Java는 그 어느 때보다 활기를 띠고 있습니다. 오늘은 Java 19의 언어 기능인 레코드 패턴 및 switch용 패턴 일치(3차 테스트 버전)에만 한정하여 다룰 예정입니다. 테스트 버전 API인 가상 스레드와 같은 다른 Java 19 기능은 의도적으로 다루지 않았습니다. IntelliJ IDEA는 가상 스레드에 대한 기본 구문 강조 표시를 지원하며, IDEA 팀은 디버거 및 프로파일러에서 가상 스레드에 대한 지원을 추가하기 위해 작업 중입니다.
Java 19 기능을 사용하도록 IntelliJ IDEA를 구성하는 방법부터 시작하겠습니다. IntelliJ IDEA 구성 Java 19에 대한 지원은 IntelliJ IDEA 2022.3에서 사용할 수 있습니다. 향후 IntelliJ IDEA 릴리스에서 더 많은 지원이 제공될 예정입니다. Java 19에서 switch 패턴 일치를 사용하려면 Project Settings(프로젝트 설정) | Project(프로젝트)로 이동하여 Project SDK를 19로 설정하고 Project language level(프로젝트 언어 수준)을 ’19 (Preview) – Record patterns, pattern matching for switch (third preview)'(19(테스트 버전) – 레코드 패턴, switch 패턴 일치(3차 테스트 버전))로 설정합니다.
이렇게 선택하면 IntelliJ IDEA가 다음 버전에서 Java 테스트 버전 언어 기능에 대한 지원을 중단할 수 있음을 알리는 팝업이 표시될 수 있습니다. 테스트 버전 기능은 아직 영구적인 것이 아니므로 향후 Java 릴리스에서 변경되거나 제거될 수 있습니다. 지금부터 레코드 패턴과 그 이점에 관해 알아보고 실습 예제를 사용해 시연해보겠습니다. 레코드 패턴이 필요한 이유 데이터는 대부분의 애플리케이션에서 핵심입니다. 데이터를 찾거나 의사 결정에 도움이 되는 방식으로 데이터를 처리하기 위해 애플리케이션을 사용하는 경우가 많습니다. 물론 애플리케이션이 데이터를 저장, 검색 또는 처리할 수 없다면 불가능한 얘기입니다. 최근 Java 릴리스(버전 16) 중 하나에서 레코드가 Java 언어에 추가되어 개발자의 데이터 작업이 더 쉬워졌습니다. 레코드는 불변의 데이터를 모델링하는 방식을 크게 단순화합니다. 말하자면 데이터에 대한 투명한 캐리어 또는 래퍼의 역할을 합니다. 한 줄의 코드만 사용하여 레코드와 해당 구성 요소를 정의할 수 있습니다. 예를 들어, 다음 한 줄의 코드는 구성 요소 name에 대한 String 값과 age에 대한 int 값을 저장할 수 있는 새 레코드 Person을 생성합니다. record Person (String name, int age) { } 레코드를 사용하면 상용구 코드를 작성하지 않아도 됩니다. 레코드는 생성자에 대한 기본 구현, 구성 요소에 대한 접근자 메서드, toString, equals 및 hashCode와 같은 유틸리티 메서드를 묵시적으로 생성합니다. 레코드를 데이터의 래퍼로 사용하는 경우, 해당 구성 요소에 액세스하려면 래핑을 해제해야 할 가능성이 높습니다. 예를 들어 레코드 Person의 인스턴스가 있는 경우, 나이 구성 요소를 검사하여 해당하는 사람에게 투표할 자격이 있는지 여부를 확인할 수 있습니다. 다음은 이 동작을 수행할 수 있는 isEligibleToVote라는 메서드입니다. boolean isEligibleToVote(Object obj) { if (obj instanceof Person person) { return person.age() >= 18; } return false; } 앞의 예에서는 패턴 변수 person을 선언하는 instanceof의 패턴 일치를 사용하므로 obj를 Person으로 변환하기 위해 지역 변수를 생성할 필요가 없습니다. 레코드 패턴은 한 단계 더 나아갑니다. 인스턴스를 레코드 타입 Person과 비교할 뿐만 아니라 레코드의 구성 요소에 대한 변수를 선언하므로 레코드의 구성 요소에 액세스하기 위해 사용자가 지역 변수를 정의하거나 패턴 변수를 사용할 필요가 없습니다. 이는 컴파일러가 레코드 구성 요소의 정확한 수와 타입을 알고 있기 때문에 가능합니다. 레코드 패턴을 사용하여 앞의 메서드를 다시 작성해 보겠습니다. instanceof 연산자 또는 switch case 라벨과 함께 레코드 타입을 사용하면 IntelliJ IDEA가 이를 탐지하여 레코드 패턴 사용을 제안할 수 있습니다. 다음은 참조용으로 수정된 코드입니다. boolean isEligibleToVote(Object obj) { if (obj instanceof Person(String name, int age)) { return age >= 18; } return false; } 앞의 코드에서 레코드 패턴 Person(String name, int age)은 person.age() 대신 변수 age를 사용했을 뿐인 것처럼 보입니다. 그러나 이 블로그 게시물을 읽으면서 레코드 패턴이 코드의 의도를 단순화하고 간결한 데이터 처리 코드를 만드는 데 도움이 된다는 사실을 알게 될 것입니다. 이전에 레코드로 작업한 적이 없거나 레코드가 무엇인지 또는 IntelliJ IDEA가 레코드를 어떻게 지원하는지 자세히 알고 싶다면 레코드에 대한 저의 이전 블로그를 참조하세요. 명명된 레코드 패턴 레코드 패턴 다음에 레코드 패턴 변수가 올 수 있습니다. 그런 경우에 레코드 패턴을 명명된 레코드 패턴이라고 합니다(확정되지는 않았지만 Java 20의 레코드 패턴 2차 테스트 버전에서 명명된 레코드 패턴에 대한 지원이 중단될 수 있음). 레코드 패턴은 해당 구성 요소에 대한 패턴 변수도 정의할 수 있습니다. 명명된 레코드 패턴을 사용하고 레코드 패턴 변수로 해당 구성 요소 중 하나에 액세스하려고 하면 IntelliJ IDEA가 사용자에게 해당 구성 요소에 패턴 변수를 사용하도록 합니다. 이러한 코드는 노란색 배경으로 강조 표시됩니다. Alt+Enter를 사용하여 이 제안을 보고 수락하여 코드를 수정할 수 있습니다. 레코드 패턴 및 null 이전 섹션의 메서드 isEligibleToVote 예시를 다시 살펴보겠습니다. null 값이 다음 메서드에 전달되면 어떻게 될까요? boolean isEligibleToVote(Object obj) { if (obj instanceof Person(String name, int age)) { return age >= 18; } return false; } null은 레코드 패턴 Person(String name, int age)의 인스턴스가 아니므로 instanceof 연산자는 false를 반환하고 패턴은 변수 name 및 age는 초기화되지 않습니다. 이렇게 되면 레코드 패턴이 null을 처리하고 사용자가 not null 검사를 정의할 필요가 없기 때문에 편리합니다. 하지만 구성 요소 name의 값이 null이면 패턴이 일치합니다. 중첩 레코드 패턴 – 간결한 코드와 명확한 의도 다른 레코드를 자신의 구성 요소로 정의하는 레코드는 흔합니다. 예를 들면 다음과 같습니다: record Name (String fName, String lName) { } record PhoneNumber(String areaCode, String number) { } record Country (String countryCode, String countryName) { } record Passenger (Name name, PhoneNumber phoneNumber, Country from, Country destination) { }
boolean checkFirstNameAndCountryCode (Object obj) { if (obj != null) { if (obj instanceof Passenger passenger) { Name name = null; Country destination = null; if (<p></p><p></p><p> </p><p></p><p></p><p> <style>
img {
max-width: 100%;
height: auto;
</style>
</p><center>
</center><p></p><p></p><center><br></center><center><table style="max-width:800px;">
<tbody><tr>
<td><p></p><p></p><p></p><p></p><p></p><p></p><p><img src="https://new.tangunsoft.com/storage/admin/editing/1678752998JetBrains_메인배너.png" data-filename="" style="width: 100%;"><span style="background-color: transparent;"><br></span></p><p style="line-height: 1.8;"><span style="background-color: transparent;"><br></span></p><p style="line-height: 1.8;"><span style="background-color: transparent;">안녕하세요. JetBrains 한국 총판 단군소프트입니다.</span></p><p style="line-height: 1.8;"><span style="background-color: transparent;">Java는 그 어느 때보다 활기를 띠고 있습니다.<br></span><span style="background-color: transparent;">릴리스 주기가 짧아져 6개월마다 새로운 언어 또는 플랫폼 기능을 시험해 볼 수 있는데요 :)<br></span><span style="background-color: transparent;">IntelliJ IDEA에서는 이러한 새로운 기능을 부담 없이 알아보고 사용해볼 수 있다는 점 알고 계셨나요??<br></span></p>
<p>오늘은 Java 19의 언어 기능인 <a href:https:="" openjdk.org="" jeps="" 405="">레코드 패턴</a> 및 <a href:https:="" openjdk.org="" jeps="" 427="">switch용 패턴 일치(3차 테스트 버전)</a>에만 한정하여 다룰 예정입니다. 테스트 버전 API인 <a href:https:="" openjdk.org="" jeps="" 425="">가상 스레드</a>와 같은 다른 Java 19 기능은 의도적으로 다루지 않았습니다. IntelliJ IDEA는 가상 스레드에 대한 기본 구문 강조 표시를 지원하며, IDEA 팀은 <a href:https:="" youtrack.jetbrains.com="" issue="" idea-301409="" support-virtual-threads-project-loom?_ga="2.196733100.1227453537.1678672110-583774747.1636506328&_gl=1*179ycco*_ga*NTgzNzc0NzQ3LjE2MzY1MDYzMjg.*_ga_9J976DJZ68*MTY3ODc3MTQ5MC4xMzMuMS4xNjc4NzcxNzY2LjAuMC4w">디버거 및 프로파일러</a>에서 가상 스레드에 대한 지원을 추가하기 위해 작업 중입니다.<br></p><p><br><span style="background-color: transparent;">레코드 패턴은 레코드 구성 요소에 대한 액세스를 단순화합니다. 인스턴스가 레코드의 구조와 일치할 때 레코드의 구성 요소 값을 변수 집합으로 추출하는 기능인 레코드 구조 분해와 레코드 패턴을 비교해보세요. 처음에는 큰 차이가 보이지 않을 수도 있습니다. 그러나 레코드 패턴을 switch 및 sealed 클래스의 패턴 일치와 같은 다른 언어 기능과 결합하면 생각하지 못한 결과에 놀라게 될 것입니다.</span></p><p><span style="background-color: transparent;"><br></span><span style="background-color: transparent;">switch 패턴 일치는 switch 문과 switch 식의 case 라벨에 패턴을 추가합니다. switch와 함께 사용할 수 있는 선택자 표현식의 타입은 모든 참조 값으로 확장됩니다. 또한 case 라벨은 더 이상 상수 값으로 제한되지 않습니다. if-else 문 체인은 switch로 대체되어 코드 가독성이 향상되었습니다. 이 블로그 게시물에서는 switch용 패턴 일치의 3차 테스트 버전에 소개된 변경 사항을 다룹니다.</span></p><p><br></p><p><img src="https://new.tangunsoft.com/storage/admin/editing/1678756996기존배너.png" data-filename="" style="width: 100%;"><span style="background-color: transparent;"><br></span></p><p><br></p><p><span style="background-color: transparent;">Java 19 기능을 사용하도록 IntelliJ IDEA를 구성하는 방법부터 시작하겠습니다.</span><br></p>
<br><p><b> <span style="font-size: 18px;">IntelliJ IDEA 구성</span></b></p><p><span style="background-color: transparent;">Java 19에 대한 지원은 IntelliJ IDEA 2022.3에서 사용할 수 있습니다. 향후 IntelliJ IDEA 릴리스에서 더 많은 지원이 제공될 예정입니다. Java 19에서 switch 패턴 일치를 사용하려면 Project Settings(프로젝트 설정) | Project(프로젝트)로 이동하여 Project SDK를 19로 설정하고 Project language level(프로젝트 언어 수준)을 ’19 (Preview) – Record patterns, pattern matching for switch (third preview)'(19(테스트 버전) – 레코드 패턴, switch 패턴 일치(3차 테스트 버전))로 설정합니다.</span></p><p><img src="https://new.tangunsoft.com/storage/admin/editing/1678757375IntelliJ IDEA 구성_01.png" data-filename="" style="width: 100%;"><br></p>
<p><br>이미 시스템에 다운로드한 임의 버전의 JDK를 사용하거나 ‘Edit'(편집)을 클릭한 다음 ‘Add SDK >'(SDK 추가)를 선택하고 ‘Download JDK…'(JDK 다운로드)를 선택하여 다른 버전을 다운로드할 수 있습니다. 다운로드할 JDK 버전은 공급업체 목록에서 선택할 수 있습니다.<br><br>Modules(모듈) 탭에서 모듈에 대해 동일한 언어 수준 즉, 19 (Preview) – Record patterns, pattern matching for switch (third preview)가 선택되었는지 확인합니다.</p>
<p></p><p><img src="https://new.tangunsoft.com/storage/admin/editing/1678757432IntelliJ IDEA 구성_02.png" data-filename="" style="width: 100%;">
</p><p></p><p><span style="background-color: transparent;"><br></span></p><p><span style="background-color: transparent;">이렇게 선택하면 IntelliJ IDEA가 다음 버전에서 Java 테스트 버전 언어 기능에 대한 지원을 중단할 수 있음을 알리는 팝업이 표시될 수 있습니다. 테스트 버전 기능은 아직 영구적인 것이 아니므로 향후 Java 릴리스에서 변경되거나 제거될 수 있습니다.</span></p><p><span style="background-color: transparent;">지금부터 레코드 패턴과 그 이점에 관해 알아보고 실습 예제를 사용해 시연해보겠습니다.</span></p><p><br></p><p></p>
<p><b><span style="font-size: 18px;">레코드 패턴이 필요한 이유</span></b></p>
<p>데이터는 대부분의 애플리케이션에서 핵심입니다. 데이터를 찾거나 의사 결정에 도움이 되는 방식으로 데이터를 처리하기 위해 애플리케이션을 사용하는 경우가 많습니다. 물론 애플리케이션이 데이터를 저장, 검색 또는 처리할 수 없다면 불가능한 얘기입니다.
</p><p>
최근 Java 릴리스(버전 16) 중 하나에서 레코드가 Java 언어에 추가되어 개발자의 데이터 작업이 더 쉬워졌습니다. 레코드는 불변의 데이터를 모델링하는 방식을 크게 단순화합니다. 말하자면 데이터에 대한 투명한 캐리어 또는 래퍼의 역할을 합니다. 한 줄의 코드만 사용하여 레코드와 해당 구성 요소를 정의할 수 있습니다.
</p><p>
예를 들어, 다음 한 줄의 코드는 구성 요소 name에 대한 String 값과 age에 대한 int 값을 저장할 수 있는 새 레코드 Person을 생성합니다.</p><p><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; font-size: 15px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre; background-color: rgb(244, 244, 244);"><br></span></p><p><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; font-size: 15px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre; background-color: rgb(244, 244, 244);">record </span><span class="enlighter-m0" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; font-size: 15px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; color: rgb(0, 134, 179); white-space: pre; background-color: rgb(244, 244, 244);">Person</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; font-size: 15px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre; background-color: rgb(244, 244, 244);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; font-size: 15px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; color: rgb(119, 119, 119); white-space: pre; background-color: rgb(244, 244, 244);">(</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; font-size: 15px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre; background-color: rgb(244, 244, 244);">String name, int age</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; font-size: 15px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; color: rgb(119, 119, 119); white-space: pre; background-color: rgb(244, 244, 244);">)</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; font-size: 15px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre; background-color: rgb(244, 244, 244);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; font-size: 15px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; color: rgb(119, 119, 119); white-space: pre; background-color: rgb(244, 244, 244);">{</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; font-size: 15px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre; background-color: rgb(244, 244, 244);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; font-size: 15px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; color: rgb(119, 119, 119); white-space: pre; background-color: rgb(244, 244, 244);">}</span></p><p><span style="background-color: transparent;"><br></span></p><p><span style="background-color: transparent;">레코드를 사용하면 상용구 코드를 작성하지 않아도 됩니다. 레코드는 생성자에 대한 기본 구현, 구성 요소에 대한 접근자 메서드, toString, equals 및 hashCode와 같은 유틸리티 메서드를 묵시적으로 생성합니다. 레코드를 데이터의 래퍼로 사용하는 경우, 해당 구성 요소에 액세스하려면 래핑을 해제해야 할 가능성이 높습니다. 예를 들어 레코드 Person의 인스턴스가 있는 경우, 나이 구성 요소를 검사하여 해당하는 사람에게 투표할 자격이 있는지 여부를 확인할 수 있습니다. 다음은 이 동작을 수행할 수 있는 isEligibleToVote라는 메서드입니다.</span></p><p><span style="background-color: transparent;"><br></span></p><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); border-radius: 8px 8px 0px 0px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">boolean </span><span class="enlighter-m0" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 134, 179);">isEligibleToVote</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">(</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">Object obj</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">)</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">{</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">if</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">(</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">obj instanceof Person person</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">)</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">{</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">return</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> person.</span><span class="enlighter-m3" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 134, 179);">age</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">()</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">></span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">= </span><span class="enlighter-n1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 153, 153);">18</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">;</span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">}</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">return</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">false</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">;</span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); border-radius: 0px 0px 8px 8px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">}</span></div></div><p><span style="background-color: transparent;"><br></span></p><p><span style="background-color: transparent;">앞의 예에서는 패턴 변수 person을 선언하는 instanceof의 패턴 일치를 사용하므로 obj를 Person으로 변환하기 위해 지역 변수를 생성할 필요가 없습니다.</span><br></p><p>
레코드 패턴은 한 단계 더 나아갑니다. 인스턴스를 레코드 타입 Person과 비교할 뿐만 아니라 레코드의 구성 요소에 대한 변수를 선언하므로 레코드의 구성 요소에 액세스하기 위해 사용자가 지역 변수를 정의하거나 패턴 변수를 사용할 필요가 없습니다. 이는 컴파일러가 레코드 구성 요소의 정확한 수와 타입을 알고 있기 때문에 가능합니다.
</p><p><span style="background-color: transparent;">레코드 패턴을 사용하여 앞의 메서드를 다시 작성해 보겠습니다. instanceof 연산자 또는 switch case 라벨과 함께 레코드 타입을 사용하면 IntelliJ IDEA가 이를 탐지하여 레코드 패턴 사용을 제안할 수 있습니다.</span></p><p><br></p><p><img src="https://new.tangunsoft.com/storage/admin/editing/1678760017레코트패턴02.gif" data-filename="" style="width: 100%;"><span style="background-color: transparent;"><br></span></p><p><br></p><p><span style="background-color: transparent;">다음은 참조용으로 수정된 코드입니다.</span></p><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); border-radius: 8px 8px 0px 0px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">boolean </span><span class="enlighter-m0" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 134, 179);">isEligibleToVote</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">(</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">Object obj</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">)</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">{</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">if</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">(</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">obj instanceof </span><span class="enlighter-m0" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 134, 179);">Person</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">(</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">String name, int age</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">))</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">{</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">return</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> age </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">></span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">= </span><span class="enlighter-n1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 153, 153);">18</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">;</span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">}</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">return</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">false</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">;</span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); border-radius: 0px 0px 8px 8px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">}</span></div><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><br></div><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);"><br></span></div></div><p><br></p><p><span style="background-color: transparent;">앞의 코드에서 레코드 패턴 Person(String name, int age)은 person.age() 대신 변수 age를 사용했을 뿐인 것처럼 보입니다. 그러나 이 블로그 게시물을 읽으면서 레코드 패턴이 코드의 의도를 단순화하고 간결한 데이터 처리 코드를 만드는 데 도움이 된다는 사실을 알게 될 것입니다.</span><br></p>
<p>이전에 레코드로 작업한 적이 없거나 레코드가 무엇인지 또는 IntelliJ IDEA가 레코드를 어떻게 지원하는지 자세히 알고 싶다면 레코드에 대한 저의 이전 블로그를 참조하세요.</p><p><br></p>
<p><b><span style="font-size: 18px;">명명된 레코드 패턴</span></b></p><p><span style="background-color: transparent;">레코드 패턴 다음에 레코드 패턴 변수가 올 수 있습니다. 그런 경우에 레코드 패턴을 명명된 레코드 패턴이라고 합니다(확정되지는 않았지만 Java 20의 레코드 패턴 2차 테스트 버전에서 명명된 레코드 패턴에 대한 지원이 중단될 수 있음).</span><br></p>
<p>레코드 패턴은 해당 구성 요소에 대한 패턴 변수도 정의할 수 있습니다. 명명된 레코드 패턴을 사용하고 레코드 패턴 변수로 해당 구성 요소 중 하나에 액세스하려고 하면 IntelliJ IDEA가 사용자에게 해당 구성 요소에 패턴 변수를 사용하도록 합니다. 이러한 코드는 노란색 배경으로 강조 표시됩니다. Alt+Enter를 사용하여 이 제안을 보고 수락하여 코드를 수정할 수 있습니다.</p><p><img src="https://new.tangunsoft.com/storage/admin/editing/1678760356명명된레코드.gif" data-filename="" style="width: 100%;"><br></p>
<p><br></p><p><b><span style="font-size: 18px;">레코드 패턴 및 null</span></b></p>
<p>이전 섹션의 메서드 isEligibleToVote 예시를 다시 살펴보겠습니다. null 값이 다음 메서드에 전달되면 어떻게 될까요?</p>
<p></p><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); border-radius: 8px 8px 0px 0px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">boolean </span><span class="enlighter-m0" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 134, 179);">isEligibleToVote</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">(</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">Object obj</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">)</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">{</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">if</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">(</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">obj instanceof </span><span class="enlighter-m0" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 134, 179);">Person</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">(</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">String name, int age</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">))</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">{</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">return</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> age </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">></span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">= </span><span class="enlighter-n1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 153, 153);">18</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">;</span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">}</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">return</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">false</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">;</span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); border-radius: 0px 0px 8px 8px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">}</span></div><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><br></div><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);"><br></span></div></div><p><br></p><p><span style="background-color: transparent;">null은 레코드 패턴 Person(String name, int age)의 인스턴스가 아니므로 instanceof 연산자는 false를 반환하고 패턴은 변수 name 및 age는 초기화되지 않습니다. 이렇게 되면 레코드 패턴이 null을 처리하고 사용자가 not null 검사를 정의할 필요가 없기 때문에 편리합니다.</span><br></p>
<p>하지만 구성 요소 name의 값이 null이면 패턴이 일치합니다.<br><br><br></p>
<p><b><span style="font-size: 18px;">중첩 레코드 패턴 – 간결한 코드와 명확한 의도</span></b></p>
<p>다른 레코드를 자신의 구성 요소로 정의하는 레코드는 흔합니다. 예를 들면 다음과 같습니다: </p><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); border-radius: 8px 8px 0px 0px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">record </span><span class="enlighter-m0" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 134, 179);">Name</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">(</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">String fName, String lName</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">)</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">{</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">}</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">record </span><span class="enlighter-m0" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 134, 179);">PhoneNumber</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">(</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">String areaCode, String number</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">)</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">{</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">}</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">record </span><span class="enlighter-m0" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 134, 179);">Country</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">(</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">String countryCode, String countryName</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">)</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">{</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">}</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">record </span><span class="enlighter-m0" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 134, 179);">Passenger</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">(</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">Name name, </span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; line-height: 1.35em; min-height: 14px; white-space: pre-wrap;"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> PhoneNumber phoneNumber, </span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; line-height: 1.35em; min-height: 14px; white-space: pre-wrap;"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> Country from, </span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; line-height: 1.35em; min-height: 14px; border-radius: 0px 0px 8px 8px; white-space: pre-wrap;"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> Country destination</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">)</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">{</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">}</span></div></div></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); border-radius: 0px 0px 8px 8px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"></div><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><br></div></div>
<p><br>null 구성 요소 값을 확인할 수 있는 레코드 패턴이 없으면 다음과 같이 Passenger 레코드의 구성 요소 값(예를 들어 fName 및 countryCode)을 처리하기 위해 몇 가지 null 확인 작업이 필요합니다.</p><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; font-size: 15px; line-height: 1.35em; min-height: 14px; color: rgb(170, 170, 170); border-radius: 8px 8px 0px 0px; font-family: JetBrainsMono, Times, Baskerville, Georgia, serif; white-space: pre-wrap; background-color: rgb(244, 244, 244);"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; line-height: 1.35em; min-height: 14px; border-radius: 8px 8px 0px 0px; white-space: pre-wrap;"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">boolean </span><span class="enlighter-m0" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 134, 179);">checkFirstNameAndCountryCode</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">(</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">Object obj</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">)</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">{</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; line-height: 1.35em; min-height: 14px; white-space: pre-wrap;"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">if</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">(</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">obj != </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">null</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">)</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">{</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; line-height: 1.35em; min-height: 14px; white-space: pre-wrap;"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">if</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">(</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">obj instanceof Passenger passenger</span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">)</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">{</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"></span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; line-height: 1.35em; min-height: 14px; white-space: pre-wrap;"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> Name name = </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">null</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">;</span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; line-height: 1.35em; min-height: 14px; white-space: pre-wrap;"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> Country destination = </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">null</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);">;</span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; line-height: 1.35em; min-height: 14px; white-space: pre-wrap;"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span></div></div><div class="" style="box-sizing: inherit; max-height: 1e+06px; display: table-row; margin: 0px; border: 0px solid rgb(255, 255, 255); list-style: none; line-height: 1.35em; min-height: 14px; white-space: pre-wrap;"><div style="box-sizing: inherit; max-height: 1e+06px; display: table-cell; padding-left: 10px; white-space: pre !important;"><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-k1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(40, 100, 145); font-weight: 700;">if</span><span class="enlighter-text" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(0, 0, 0);"> </span><span class="enlighter-g1" style="box-sizing: inherit; max-height: 1e+06px; margin: 0px; padding: 0px; line-height: inherit; color: rgb(119, 119, 119);">(</span><span class="enlighter-text" style="box-sizing: inherit; max- -->
|