❓ Wrapper class?
기본 타입(원시 타입)을 객체로 다루기 위해 사용하는 클래스
ex) int : Integer (기본, wrapper), char : Character (기본, wrapper)
// Order 타입의 객체를 감쌀 수 있는 Optional 타입의 변수
Optional<Order> maybeOrder;
// Member 타입의 객체를 감쌀 수 있는 Optional 타입의 변수
Optional<Member> optMember;
Optional<Member> maybeMember = Optional.of(aMember);
// Optional의 value는 값이 있을 수도 있고 null 일 수도 있다.
Optional<String> optional = Optional.ofNullable(getName());
// 값이 없다면 "anonymous" 를 리턴
String name = optional.orElse("anonymous");
Optional<String> optStr = Optional.ofNullable(null);
String result = optStr.orElse("Value = null”);
System.out.println(result); // Value = null
String str = "test";
//null이 아니여도 getDefaultValue() 함수는 실행함
String result1 = Optional.ofNullable(str).orElse(getDefaultValue());
LOG.info("orElse result: {}", result1);
// getDefaultValue() 실행하지 않음
String result2 = Optional.ofNullable(str).orElseGet(this::getDefaultValue);
LOG.info("orElseGet result: {}", result2);