Skip to content

Commit

Permalink
값객체 equals, hashcode 정의
Browse files Browse the repository at this point in the history
  • Loading branch information
songyi00 committed Aug 8, 2024
1 parent 3060f30 commit 3d004ca
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;

import java.util.Objects;
import java.util.Random;

import static com.nexters.goalpanzi.exception.ErrorCode.INVALID_INVITATION_CODE;
Expand Down Expand Up @@ -46,4 +47,24 @@ private void validate() {
throw new IllegalArgumentException(INVALID_INVITATION_CODE.getMessage());
}
}

@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
InvitationCode code1 = (InvitationCode) o;
return Objects.equals(code, code1.code);
}

@Override
public int hashCode() {
return Objects.hashCode(code);
}

@Override
public String toString() {
return "InvitationCode{" +
"code='" + code + '\'' +
'}';
}
}

0 comments on commit 3d004ca

Please sign in to comment.