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

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

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import java.io.Serializable;

import java.sql.Types;

import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the EmailDestinatario service. Represents a row in the &quot;PRT_GESTMSG_MAIL_DESTINATARIO&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link br.mp.mprj.portal.portlet.gestaomensagens.service.model.EmailDestinatarioModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link EmailDestinatarioImpl}.
 * </p>
 *
 * @author Henrique Simoes
 * @see EmailDestinatarioImpl
 * @see br.mp.mprj.portal.portlet.gestaomensagens.service.model.EmailDestinatario
 * @see br.mp.mprj.portal.portlet.gestaomensagens.service.model.EmailDestinatarioModel
 * @generated
 */
public class EmailDestinatarioModelImpl extends BaseModelImpl<EmailDestinatario>
    implements EmailDestinatarioModel {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never modify or reference this class directly. All methods that expect a email destinatario model instance should use the {@link br.mp.mprj.portal.portlet.gestaomensagens.service.model.EmailDestinatario} interface instead.
     */
    public static final String TABLE_NAME = "PRT_GESTMSG_MAIL_DESTINATARIO";
    public static final Object[][] TABLE_COLUMNS = {
            { "uuid_", Types.VARCHAR },
            { "emailDestinatarioId", Types.BIGINT },
            { "email", Types.VARCHAR },
            { "grupoDestinatarioId", Types.BIGINT }
        };
    public static final String TABLE_SQL_CREATE = "create table PRT_GESTMSG_MAIL_DESTINATARIO (uuid_ VARCHAR(75) null,emailDestinatarioId LONG not null primary key,email VARCHAR(75) null,grupoDestinatarioId LONG)";
    public static final String TABLE_SQL_DROP = "drop table PRT_GESTMSG_MAIL_DESTINATARIO";
    public static final String ORDER_BY_JPQL = " ORDER BY emailDestinatario.emailDestinatarioId ASC";
    public static final String ORDER_BY_SQL = " ORDER BY PRT_GESTMSG_MAIL_DESTINATARIO.emailDestinatarioId ASC";
    public static final String DATA_SOURCE = "liferayDataSource";
    public static final String SESSION_FACTORY = "liferaySessionFactory";
    public static final String TX_MANAGER = "liferayTransactionManager";
    public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.entity.cache.enabled.br.mp.mprj.portal.portlet.gestaomensagens.service.model.EmailDestinatario"),
            true);
    public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.finder.cache.enabled.br.mp.mprj.portal.portlet.gestaomensagens.service.model.EmailDestinatario"),
            true);
    public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.column.bitmask.enabled.br.mp.mprj.portal.portlet.gestaomensagens.service.model.EmailDestinatario"),
            true);
    public static long GRUPODESTINATARIOID_COLUMN_BITMASK = 1L;
    public static long UUID_COLUMN_BITMASK = 2L;
    public static long EMAILDESTINATARIOID_COLUMN_BITMASK = 4L;
    public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
                "lock.expiration.time.br.mp.mprj.portal.portlet.gestaomensagens.service.model.EmailDestinatario"));
    private static ClassLoader _classLoader = EmailDestinatario.class.getClassLoader();
    private static Class<?>[] _escapedModelInterfaces = new Class[] {
            EmailDestinatario.class
        };
    private String _uuid;
    private String _originalUuid;
    private long _emailDestinatarioId;
    private String _email;
    private long _grupoDestinatarioId;
    private long _originalGrupoDestinatarioId;
    private boolean _setOriginalGrupoDestinatarioId;
    private long _columnBitmask;
    private EmailDestinatario _escapedModel;

    public EmailDestinatarioModelImpl() {
    }

    @Override
    public long getPrimaryKey() {
        return _emailDestinatarioId;
    }

    @Override
    public void setPrimaryKey(long primaryKey) {
        setEmailDestinatarioId(primaryKey);
    }

    @Override
    public Serializable getPrimaryKeyObj() {
        return _emailDestinatarioId;
    }

    @Override
    public void setPrimaryKeyObj(Serializable primaryKeyObj) {
        setPrimaryKey(((Long) primaryKeyObj).longValue());
    }

    @Override
    public Class<?> getModelClass() {
        return EmailDestinatario.class;
    }

    @Override
    public String getModelClassName() {
        return EmailDestinatario.class.getName();
    }

    @Override
    public Map<String, Object> getModelAttributes() {
        Map<String, Object> attributes = new HashMap<String, Object>();

        attributes.put("uuid", getUuid());
        attributes.put("emailDestinatarioId", getEmailDestinatarioId());
        attributes.put("email", getEmail());
        attributes.put("grupoDestinatarioId", getGrupoDestinatarioId());

        return attributes;
    }

    @Override
    public void setModelAttributes(Map<String, Object> attributes) {
        String uuid = (String) attributes.get("uuid");

        if (uuid != null) {
            setUuid(uuid);
        }

        Long emailDestinatarioId = (Long) attributes.get("emailDestinatarioId");

        if (emailDestinatarioId != null) {
            setEmailDestinatarioId(emailDestinatarioId);
        }

        String email = (String) attributes.get("email");

        if (email != null) {
            setEmail(email);
        }

        Long grupoDestinatarioId = (Long) attributes.get("grupoDestinatarioId");

        if (grupoDestinatarioId != null) {
            setGrupoDestinatarioId(grupoDestinatarioId);
        }
    }

    @Override
    public String getUuid() {
        if (_uuid == null) {
            return StringPool.BLANK;
        } else {
            return _uuid;
        }
    }

    @Override
    public void setUuid(String uuid) {
        if (_originalUuid == null) {
            _originalUuid = _uuid;
        }

        _uuid = uuid;
    }

    public String getOriginalUuid() {
        return GetterUtil.getString(_originalUuid);
    }

    @Override
    public long getEmailDestinatarioId() {
        return _emailDestinatarioId;
    }

    @Override
    public void setEmailDestinatarioId(long emailDestinatarioId) {
        _emailDestinatarioId = emailDestinatarioId;
    }

    @Override
    public String getEmail() {
        if (_email == null) {
            return StringPool.BLANK;
        } else {
            return _email;
        }
    }

    @Override
    public void setEmail(String email) {
        _email = email;
    }

    @Override
    public long getGrupoDestinatarioId() {
        return _grupoDestinatarioId;
    }

    @Override
    public void setGrupoDestinatarioId(long grupoDestinatarioId) {
        _columnBitmask |= GRUPODESTINATARIOID_COLUMN_BITMASK;

        if (!_setOriginalGrupoDestinatarioId) {
            _setOriginalGrupoDestinatarioId = true;

            _originalGrupoDestinatarioId = _grupoDestinatarioId;
        }

        _grupoDestinatarioId = grupoDestinatarioId;
    }

    public long getOriginalGrupoDestinatarioId() {
        return _originalGrupoDestinatarioId;
    }

    public long getColumnBitmask() {
        return _columnBitmask;
    }

    @Override
    public ExpandoBridge getExpandoBridge() {
        return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
            EmailDestinatario.class.getName(), getPrimaryKey());
    }

    @Override
    public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
        ExpandoBridge expandoBridge = getExpandoBridge();

        expandoBridge.setAttributes(serviceContext);
    }

    @Override
    public EmailDestinatario toEscapedModel() {
        if (_escapedModel == null) {
            _escapedModel = (EmailDestinatario) ProxyUtil.newProxyInstance(_classLoader,
                    _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
        }

        return _escapedModel;
    }

    @Override
    public Object clone() {
        EmailDestinatarioImpl emailDestinatarioImpl = new EmailDestinatarioImpl();

        emailDestinatarioImpl.setUuid(getUuid());
        emailDestinatarioImpl.setEmailDestinatarioId(getEmailDestinatarioId());
        emailDestinatarioImpl.setEmail(getEmail());
        emailDestinatarioImpl.setGrupoDestinatarioId(getGrupoDestinatarioId());

        emailDestinatarioImpl.resetOriginalValues();

        return emailDestinatarioImpl;
    }

    @Override
    public int compareTo(EmailDestinatario emailDestinatario) {
        long primaryKey = emailDestinatario.getPrimaryKey();

        if (getPrimaryKey() < primaryKey) {
            return -1;
        } else if (getPrimaryKey() > primaryKey) {
            return 1;
        } else {
            return 0;
        }
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }

        if (!(obj instanceof EmailDestinatario)) {
            return false;
        }

        EmailDestinatario emailDestinatario = (EmailDestinatario) obj;

        long primaryKey = emailDestinatario.getPrimaryKey();

        if (getPrimaryKey() == primaryKey) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (int) getPrimaryKey();
    }

    @Override
    public void resetOriginalValues() {
        EmailDestinatarioModelImpl emailDestinatarioModelImpl = this;

        emailDestinatarioModelImpl._originalUuid = emailDestinatarioModelImpl._uuid;

        emailDestinatarioModelImpl._originalGrupoDestinatarioId = emailDestinatarioModelImpl._grupoDestinatarioId;

        emailDestinatarioModelImpl._setOriginalGrupoDestinatarioId = false;

        emailDestinatarioModelImpl._columnBitmask = 0;
    }

    @Override
    public CacheModel<EmailDestinatario> toCacheModel() {
        EmailDestinatarioCacheModel emailDestinatarioCacheModel = new EmailDestinatarioCacheModel();

        emailDestinatarioCacheModel.uuid = getUuid();

        String uuid = emailDestinatarioCacheModel.uuid;

        if ((uuid != null) && (uuid.length() == 0)) {
            emailDestinatarioCacheModel.uuid = null;
        }

        emailDestinatarioCacheModel.emailDestinatarioId = getEmailDestinatarioId();

        emailDestinatarioCacheModel.email = getEmail();

        String email = emailDestinatarioCacheModel.email;

        if ((email != null) && (email.length() == 0)) {
            emailDestinatarioCacheModel.email = null;
        }

        emailDestinatarioCacheModel.grupoDestinatarioId = getGrupoDestinatarioId();

        return emailDestinatarioCacheModel;
    }

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

        sb.append("{uuid=");
        sb.append(getUuid());
        sb.append(", emailDestinatarioId=");
        sb.append(getEmailDestinatarioId());
        sb.append(", email=");
        sb.append(getEmail());
        sb.append(", grupoDestinatarioId=");
        sb.append(getGrupoDestinatarioId());
        sb.append("}");

        return sb.toString();
    }

    @Override
    public String toXmlString() {
        StringBundler sb = new StringBundler(16);

        sb.append("<model><model-name>");
        sb.append(
            "br.mp.mprj.portal.portlet.gestaomensagens.service.model.EmailDestinatario");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>uuid</column-name><column-value><![CDATA[");
        sb.append(getUuid());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>emailDestinatarioId</column-name><column-value><![CDATA[");
        sb.append(getEmailDestinatarioId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>email</column-name><column-value><![CDATA[");
        sb.append(getEmail());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>grupoDestinatarioId</column-name><column-value><![CDATA[");
        sb.append(getGrupoDestinatarioId());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
