-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
139 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/net/teumteum/user/domain/BalanceGameType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package net.teumteum.user.domain; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.function.BiFunction; | ||
import net.teumteum.user.domain.response.InterestQuestionResponse; | ||
|
||
public enum BalanceGameType { | ||
|
||
BALANCE("balance", (users, interestQuestion) -> interestQuestion.getBalanceGame(users)), | ||
STORY("story", (users, interestQuestion) -> interestQuestion.getStoryGame(users)), | ||
; | ||
|
||
private final String value; | ||
private final BiFunction<List<User>, InterestQuestion, InterestQuestionResponse> behavior; | ||
|
||
BalanceGameType(String value, BiFunction<List<User>, InterestQuestion, InterestQuestionResponse> behavior) { | ||
this.value = value; | ||
this.behavior = behavior; | ||
} | ||
|
||
public static BalanceGameType of(String value) { | ||
return Arrays.stream(BalanceGameType.values()) | ||
.filter(type -> type.value.equals(value)) | ||
.findAny() | ||
.orElseThrow( | ||
() -> new IllegalArgumentException("\"" + value + "\" 에 해당하는 enum값을 찾을 수 없습니다.") | ||
); | ||
} | ||
|
||
public InterestQuestionResponse getInterestQuestionResponse(List<User> users, InterestQuestion interestQuestion) { | ||
return behavior.apply(users, interestQuestion); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
package net.teumteum.user.domain; | ||
|
||
import java.util.List; | ||
import net.teumteum.user.domain.response.InterestQuestionResponse; | ||
import net.teumteum.user.domain.response.BalanceQuestionResponse; | ||
import net.teumteum.user.domain.response.StoryQuestionResponse; | ||
|
||
@FunctionalInterface | ||
public interface InterestQuestion { | ||
|
||
InterestQuestionResponse getQuestion(List<User> users); | ||
BalanceQuestionResponse getBalanceGame(List<User> users); | ||
|
||
StoryQuestionResponse getStoryGame(List<User> users); | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/net/teumteum/user/domain/response/BalanceQuestionResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package net.teumteum.user.domain.response; | ||
|
||
import java.util.List; | ||
|
||
public record BalanceQuestionResponse( | ||
String topic, | ||
List<String> balanceQuestion | ||
) implements InterestQuestionResponse { | ||
|
||
} |
7 changes: 1 addition & 6 deletions
7
src/main/java/net/teumteum/user/domain/response/InterestQuestionResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
package net.teumteum.user.domain.response; | ||
|
||
import java.util.List; | ||
|
||
public record InterestQuestionResponse( | ||
String topic, | ||
List<String> balanceQuestion | ||
) { | ||
public interface InterestQuestionResponse { | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/net/teumteum/user/domain/response/StoryQuestionResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package net.teumteum.user.domain.response; | ||
|
||
public record StoryQuestionResponse( | ||
String topic, | ||
String story | ||
) implements InterestQuestionResponse { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters