package tutorial.rest.resources.asm;

import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
import java.util.List;
import tutorial.core.services.util.MessageList;
import tutorial.rest.mvc.MessageController;
import tutorial.rest.resources.MessageListResource;
import tutorial.rest.resources.MessageResource;

/**
 * 
 * @author Xavier
 */
public class MessageListResourceAsm extends ResourceAssemblerSupport<MessageList, MessageListResource> {

    /**
     *
     */
    public MessageListResourceAsm() {
        super(MessageController.class, MessageListResource.class);
    }

    /**
     *
     * @param messageList
     * @return
     */
    @Override
    public MessageListResource toResource(MessageList messageList) {
        List<MessageResource> resList = new MessageResourceAsm().toResources(messageList.getMessages());
        MessageListResource finalRes = new MessageListResource();
        finalRes.setMessages(resList);
        return finalRes;
    }
}
