package br.mp.mprj.portal.portlet.gestaomensagens.service.model.impl;

import br.mp.mprj.portal.portlet.gestaomensagens.service.model.EmailDestinatario;

import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;

/**
 * The cache model class for representing EmailDestinatario in entity cache.
 *
 * @author Henrique Simoes
 * @see EmailDestinatario
 * @generated
 */
public class EmailDestinatarioCacheModel implements CacheModel<EmailDestinatario>,
    Externalizable {
    public String uuid;
    public long emailDestinatarioId;
    public String email;
    public long grupoDestinatarioId;

    @Override
    public String toString() {
        StringBundler sb = new StringBundler(9);

        sb.append("{uuid=");
        sb.append(uuid);
        sb.append(", emailDestinatarioId=");
        sb.append(emailDestinatarioId);
        sb.append(", email=");
        sb.append(email);
        sb.append(", grupoDestinatarioId=");
        sb.append(grupoDestinatarioId);
        sb.append("}");

        return sb.toString();
    }

    @Override
    public EmailDestinatario toEntityModel() {
        EmailDestinatarioImpl emailDestinatarioImpl = new EmailDestinatarioImpl();

        if (uuid == null) {
            emailDestinatarioImpl.setUuid(StringPool.BLANK);
        } else {
            emailDestinatarioImpl.setUuid(uuid);
        }

        emailDestinatarioImpl.setEmailDestinatarioId(emailDestinatarioId);

        if (email == null) {
            emailDestinatarioImpl.setEmail(StringPool.BLANK);
        } else {
            emailDestinatarioImpl.setEmail(email);
        }

        emailDestinatarioImpl.setGrupoDestinatarioId(grupoDestinatarioId);

        emailDestinatarioImpl.resetOriginalValues();

        return emailDestinatarioImpl;
    }

    @Override
    public void readExternal(ObjectInput objectInput) throws IOException {
        uuid = objectInput.readUTF();
        emailDestinatarioId = objectInput.readLong();
        email = objectInput.readUTF();
        grupoDestinatarioId = objectInput.readLong();
    }

    @Override
    public void writeExternal(ObjectOutput objectOutput)
        throws IOException {
        if (uuid == null) {
            objectOutput.writeUTF(StringPool.BLANK);
        } else {
            objectOutput.writeUTF(uuid);
        }

        objectOutput.writeLong(emailDestinatarioId);

        if (email == null) {
            objectOutput.writeUTF(StringPool.BLANK);
        } else {
            objectOutput.writeUTF(email);
        }

        objectOutput.writeLong(grupoDestinatarioId);
    }
}
