package com.demo1.board.api.dto;

import java.util.List;
import java.util.stream.Collectors;

import org.springframework.data.domain.Page;

import com.demo1.board.domain.Board;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

@Data
@AllArgsConstructor
@Builder
public class BoardResponse {
    private String title;
    private String content;

    public static BoardResponse of(Board board) {
        return BoardResponse.builder()
                .title(board.getTitle())
                .content(board.getContent())
                .build();
    }

    public static List<BoardResponse> listOf(List<Board> boards) {
        return boards.stream()
                .map(BoardResponse::of)
                .collect(Collectors.toList());
    }

	public static Page<BoardResponse> pageOf(Page<Board> boards) {
		return boards.map(BoardResponse::of);
	}
}
