스터디 · 모집완료
자바 백엔드 이력서기반 + CS 모의 면접 스터디 (경력 2년이상)
- 좋아요수
- 0
- 댓글수
- 0
- 조회수
- 487
스터디 · 모집완료
질문&답변
private SearchResponse createResponse(Document document) { String author = Optional.ofNullable(document.authors()) .filter(authors -> !authors.isEmpty()) .map(List::getFirst) .orElse("Unknown Author"); String publisher = Optional.ofNullable(document.publisher()) .filter(p -> !p.isBlank()) .orElse("Unknown Publisher"); return SearchResponse.builder() .title(document.title()) .author(author) .publisher(publisher) .pubDate(DateUtils.parseOffsetDateTime(document.dateTime()).toLocalDate()) .isbn(document.isbn()) .build(); } 요런식으로 createResponse 부분만 Optional을 이용해서 null 처리 해주면 될 것 같네요.
스터디 · 모집완료
스터디 · 모집완료