Package org.cedj.geekseek.web.rest.attachment.model

Source Code of org.cedj.geekseek.web.rest.attachment.model.AttachmentRepresentationConverter

package org.cedj.geekseek.web.rest.attachment.model;

import javax.enterprise.context.RequestScoped;
import javax.ws.rs.core.UriInfo;

import org.cedj.geekseek.domain.attachment.model.Attachment;
import org.cedj.geekseek.web.rest.core.RepresentationConverter;

@RequestScoped
public class AttachmentRepresentationConverter extends RepresentationConverter.Base<AttachmentRepresentation, Attachment> {

    public AttachmentRepresentationConverter() {
        super(AttachmentRepresentation.class, Attachment.class);
    }

    @Override
    public AttachmentRepresentation from(UriInfo uriInfo, Attachment source) {
        AttachmentRepresentation rep = new AttachmentRepresentation(source.getId(), uriInfo);
        rep.setTitle(source.getTitle());
        rep.setMimeType(source.getMimeType());
        rep.setUrl(source.getUrl());
        return rep;
    }

    @Override
    public Attachment to(UriInfo uriInfo, AttachmentRepresentation representation) {
        Attachment attachment = new Attachment(
            representation.getTitle(),
            representation.getMimeType(),
            representation.getUrl());
        return attachment;
    }

    @Override
    public Attachment update(UriInfo uriInfo, AttachmentRepresentation representation, Attachment target) {
        return target.setTitle(representation.getTitle())
                     .setMimeType(representation.getMimeType())
                     .setUrl(representation.getUrl());
    }
}
TOP

Related Classes of org.cedj.geekseek.web.rest.attachment.model.AttachmentRepresentationConverter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.