meals-made-easy-api/src/main/java/app/mealsmadeeasy/api/recipe/comment/RecipeCommentView.java
2026-01-15 22:18:08 -06:00

37 lines
1.0 KiB
Java

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;
}