Skip to content

Commit

Permalink
[#54] feat: Follow 인스턴스 빌더 기능 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
kwj1270 committed Oct 3, 2021
1 parent c9a13dc commit 468e815
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
41 changes: 38 additions & 3 deletions src/main/java/com/study/realworld/domain/follow/domain/Follow.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,44 @@
package com.study.realworld.domain.follow.domain;

import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;

import javax.persistence.Entity;
import com.study.realworld.domain.user.domain.User;

public class Follow {

private User following;
private User follower;

protected Follow() {
}

private Follow(final FollowBuilder followBuilder) {
following = followBuilder.following;
follower = followBuilder.follower;
}

public static FollowBuilder Builder() {
return new FollowBuilder();
}

public static final class FollowBuilder {
private User following;
private User follower;

private FollowBuilder() {
}

public FollowBuilder following(final User following) {
this.following = following;
return this;
}

public FollowBuilder follower(final User follower) {
this.follower = follower;
return this;
}

public Follow build() {
return new Follow(this);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void builder_test() {
final User user1 = userBuilder(new Email(EMAIL), new Name(USERNAME), new Password(PASSWORD), new Bio(BIO), new Image(IMAGE));
final User user2 = userBuilder(new Email("Email2@email.com"), new Name("differentUserName"), new Password("Password2"), new Bio("Bio2"), new Image("Image2"));

final Follow follow = new Follow.Builder()
final Follow follow = Follow.Builder()
.following(user1)
.follower(user2)
.build();
Expand All @@ -43,5 +43,4 @@ void builder_test() {
);
}


}

0 comments on commit 468e815

Please sign in to comment.