package tutorial.rest.resources.asm;

import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
import tutorial.core.models.entities.Message;
import tutorial.rest.mvc.MessageController;
import tutorial.rest.resources.MessageResource;

/**
 * 
 * @author Xavier
 */
public class MessageResourceAsm extends ResourceAssemblerSupport<Message, MessageResource> {

    /**
     *
     */
    public MessageResourceAsm() {
        super(MessageController.class, MessageResource.class);
    }

    /**
     *
     * @param message
     * @return
     */
    @Override
    public MessageResource toResource(Message message) {
        MessageResource res = new MessageResource();
        res.setMessageText(message.getMessageText());
        res.setCreated(message.getCreated());
        return res;
    }
}
