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
// Record to build | |
public record NameAge(String firstName, String lastName, Option<String> middleName, int age) { | |
static NameAgeBuilderStage1 builder() { | |
return firstName -> lastName -> middleName -> age -> new NameAge(firstName, lastName, middleName, age); | |
} | |
interface NameAgeBuilderStage1 { NameAgeBuilderStage2 firstName(String firstName); } | |
interface NameAgeBuilderStage2 { NameAgeBuilderStage3 lastName(String lastName); } | |
interface NameAgeBuilderStage3 { NameAgeBuilderStage4 middleName(Option<String> middleName); } |
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
public Promise<Comment.Id> addComment(Option<User.Id> userId, Option<Publication.Id> publicationId, Option<String> commentText) { | |
return | |
validateAndLoad(userId, publicationId, commentText) | |
.map(this::makeComment) | |
.flatMap(commentService::addComment); | |
} | |
private Comment makeComment(User user, Publication publication, String comment) { | |
return Comment.newComment(user.id(), publication.id(), comment); | |
} |
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
public Result<Comment.Id> addComment(Option<User.Id> userId, Option<Publication.Id> publicationId, Option<String> commentText) { | |
return | |
validateAndLoad(userId, publicationId, commentText) | |
.map(SimpleCallFPRefactored::makeComment) | |
.flatMap(commentService::addComment); | |
} | |
private static Comment makeComment(User user, Publication publication, String comment) { | |
return Comment.newComment(user.id(), publication.id(), comment); | |
} |
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
public Result<Comment.Id> addComment(Option<User.Id> userId, Option<Publication.Id> publicationId, Option<String> commentText) { | |
return | |
all( | |
userId.toResult(Errors.UNKNOWN_USER).flatMap(userService::find), | |
publicationId.toResult(Errors.UNKNOWN_PUBLICATION).flatMap(publicationService::find), | |
commentText.toResult(Errors.INVALID_COMMENT) | |
).map((user, publication, comment) -> Comment.newComment(user.id(), publication.id(), comment)) | |
.flatMap(commentService::addComment); | |
} |
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
... | |
var value1 = service1.find(...); | |
... | |
var value2 = service2.find(value1.field1()); | |
... | |
var value3 = service3.find(value2.field2()); | |
... |
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
... | |
var comment = commentService.find(commentId); | |
var commentStats = commentStatsService.find(comment.statsId()); | |
... |
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
public Comment.Id addComment(User.Id userId, Publication.Id publicationId, String commentText) { | |
validateAddCommentParameters(userId, publicationId, commentText); | |
return commentService.addComment(makeComment(userId, publicationId, commentText)); | |
} | |
private static Comment makeComment(User.Id userId, Publication.Id publicationId, String commentText) { | |
return Comment.newComment(userId, publicationId, commentText); | |
} |
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
public Comment.Id addComment(User.Id userId, Publication.Id publicationId, String commentText) { | |
if (userId == null || userService.find(userId) == null) { | |
throw new UnknownUserException(); | |
} | |
if (publicationId == null || publicationService.find(publicationId) == null) { | |
throw new UnknownPublicationException(); | |
} | |
if (commentText == null) { |
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
import java.util.List; | |
import java.util.Optional; | |
import java.util.Set; | |
import java.util.stream.Collectors; | |
@Singleton | |
public class FeatureModelsType { | |
public static final int FEATURE_ANY_OPTION_INDEX = 0; | |
private final Context context; |
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
operation1(args...) | |
.flatMap(value1 -> operation2(args...)) | |
.flatMap(value2 -> operation3(args...)) | |
... | |
.flatMap(valueN-1 -> operationN(args...)); |
NewerOlder