package app.mealsmadeeasy.api.recipe.comment; import app.mealsmadeeasy.api.user.view.UserInfoView; import lombok.Builder; import lombok.Value; import org.jetbrains.annotations.Nullable; import java.time.OffsetDateTime; @Value @Builder public class RecipeCommentView { public static RecipeCommentView from(RecipeComment comment, boolean includeRawText) { final var builder = RecipeCommentView.builder() .id(comment.getId()) .created(comment.getCreated()) .modified(comment.getModified()) .text(comment.getCachedRenderedText()) .owner(UserInfoView.from(comment.getOwner())) .recipeId(comment.getRecipe().getId()); if (includeRawText) { builder.rawText(comment.getRawText()); } return builder.build(); } Integer id; OffsetDateTime created; @Nullable OffsetDateTime modified; String text; @Nullable String rawText; UserInfoView owner; Integer recipeId; }