Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public ProfileJpaEntity(
public void edit(final EditProfileRequest request) {
this.email = request.email();
this.education = request.education();
this.schoolInfo = request.schoolInfo().toEntity();
this.schoolInfo = request.schoolInfo() != null ? request.schoolInfo().toEntity() : null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Good catch adding the null check to prevent a NullPointerException. For a more modern and fluent approach, you could use java.util.Optional. This avoids the duplicate call to request.schoolInfo() and can improve readability.

You'll need to add an import for java.util.Optional at the top of the file.

Suggested change
this.schoolInfo = request.schoolInfo() != null ? request.schoolInfo().toEntity() : null;
this.schoolInfo = java.util.Optional.ofNullable(request.schoolInfo()).map(info -> info.toEntity()).orElse(null);

this.grade = request.grade();
}

Expand Down