/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.liferay.sync.model.impl;

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.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 com.liferay.sync.model.SyncDLFileVersionDiff;
import com.liferay.sync.model.SyncDLFileVersionDiffModel;

import java.io.Serializable;

import java.sql.Types;

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

/**
 * The base model implementation for the SyncDLFileVersionDiff service. Represents a row in the &quot;SyncDLFileVersionDiff&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.liferay.sync.model.SyncDLFileVersionDiffModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link SyncDLFileVersionDiffImpl}.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see SyncDLFileVersionDiffImpl
 * @see com.liferay.sync.model.SyncDLFileVersionDiff
 * @see com.liferay.sync.model.SyncDLFileVersionDiffModel
 * @generated
 */
public class SyncDLFileVersionDiffModelImpl extends BaseModelImpl<SyncDLFileVersionDiff>
	implements SyncDLFileVersionDiffModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a sync d l file version diff model instance should use the {@link com.liferay.sync.model.SyncDLFileVersionDiff} interface instead.
	 */
	public static final String TABLE_NAME = "SyncDLFileVersionDiff";
	public static final Object[][] TABLE_COLUMNS = {
			{ "syncDLFileVersionDiffId", Types.BIGINT },
			{ "fileEntryId", Types.BIGINT },
			{ "sourceFileVersionId", Types.BIGINT },
			{ "targetFileVersionId", Types.BIGINT },
			{ "dataFileEntryId", Types.BIGINT },
			{ "size_", Types.BIGINT },
			{ "expirationDate", Types.TIMESTAMP }
		};
	public static final String TABLE_SQL_CREATE = "create table SyncDLFileVersionDiff (syncDLFileVersionDiffId LONG not null primary key,fileEntryId LONG,sourceFileVersionId LONG,targetFileVersionId LONG,dataFileEntryId LONG,size_ LONG,expirationDate DATE null)";
	public static final String TABLE_SQL_DROP = "drop table SyncDLFileVersionDiff";
	public static final String ORDER_BY_JPQL = " ORDER BY syncDLFileVersionDiff.syncDLFileVersionDiffId ASC";
	public static final String ORDER_BY_SQL = " ORDER BY SyncDLFileVersionDiff.syncDLFileVersionDiffId 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.com.liferay.sync.model.SyncDLFileVersionDiff"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.liferay.sync.model.SyncDLFileVersionDiff"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.liferay.sync.model.SyncDLFileVersionDiff"),
			true);
	public static long EXPIRATIONDATE_COLUMN_BITMASK = 1L;
	public static long FILEENTRYID_COLUMN_BITMASK = 2L;
	public static long SOURCEFILEVERSIONID_COLUMN_BITMASK = 4L;
	public static long TARGETFILEVERSIONID_COLUMN_BITMASK = 8L;
	public static long SYNCDLFILEVERSIONDIFFID_COLUMN_BITMASK = 16L;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.liferay.sync.model.SyncDLFileVersionDiff"));

	public SyncDLFileVersionDiffModelImpl() {
	}


	public long getPrimaryKey() {
		return _syncDLFileVersionDiffId;
	}


	public void setPrimaryKey(long primaryKey) {
		setSyncDLFileVersionDiffId(primaryKey);
	}


	public Serializable getPrimaryKeyObj() {
		return _syncDLFileVersionDiffId;
	}


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


	public Class<?> getModelClass() {
		return SyncDLFileVersionDiff.class;
	}


	public String getModelClassName() {
		return SyncDLFileVersionDiff.class.getName();
	}


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

		attributes.put("syncDLFileVersionDiffId", getSyncDLFileVersionDiffId());
		attributes.put("fileEntryId", getFileEntryId());
		attributes.put("sourceFileVersionId", getSourceFileVersionId());
		attributes.put("targetFileVersionId", getTargetFileVersionId());
		attributes.put("dataFileEntryId", getDataFileEntryId());
		attributes.put("size", getSize());
		attributes.put("expirationDate", getExpirationDate());

		return attributes;
	}


	public void setModelAttributes(Map<String, Object> attributes) {
		Long syncDLFileVersionDiffId = (Long)attributes.get(
				"syncDLFileVersionDiffId");

		if (syncDLFileVersionDiffId != null) {
			setSyncDLFileVersionDiffId(syncDLFileVersionDiffId);
		}

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

		if (fileEntryId != null) {
			setFileEntryId(fileEntryId);
		}

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

		if (sourceFileVersionId != null) {
			setSourceFileVersionId(sourceFileVersionId);
		}

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

		if (targetFileVersionId != null) {
			setTargetFileVersionId(targetFileVersionId);
		}

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

		if (dataFileEntryId != null) {
			setDataFileEntryId(dataFileEntryId);
		}

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

		if (size != null) {
			setSize(size);
		}

		Date expirationDate = (Date)attributes.get("expirationDate");

		if (expirationDate != null) {
			setExpirationDate(expirationDate);
		}
	}


	public long getSyncDLFileVersionDiffId() {
		return _syncDLFileVersionDiffId;
	}


	public void setSyncDLFileVersionDiffId(long syncDLFileVersionDiffId) {
		_syncDLFileVersionDiffId = syncDLFileVersionDiffId;
	}


	public long getFileEntryId() {
		return _fileEntryId;
	}


	public void setFileEntryId(long fileEntryId) {
		_columnBitmask |= FILEENTRYID_COLUMN_BITMASK;

		if (!_setOriginalFileEntryId) {
			_setOriginalFileEntryId = true;

			_originalFileEntryId = _fileEntryId;
		}

		_fileEntryId = fileEntryId;
	}

	public long getOriginalFileEntryId() {
		return _originalFileEntryId;
	}


	public long getSourceFileVersionId() {
		return _sourceFileVersionId;
	}


	public void setSourceFileVersionId(long sourceFileVersionId) {
		_columnBitmask |= SOURCEFILEVERSIONID_COLUMN_BITMASK;

		if (!_setOriginalSourceFileVersionId) {
			_setOriginalSourceFileVersionId = true;

			_originalSourceFileVersionId = _sourceFileVersionId;
		}

		_sourceFileVersionId = sourceFileVersionId;
	}

	public long getOriginalSourceFileVersionId() {
		return _originalSourceFileVersionId;
	}


	public long getTargetFileVersionId() {
		return _targetFileVersionId;
	}


	public void setTargetFileVersionId(long targetFileVersionId) {
		_columnBitmask |= TARGETFILEVERSIONID_COLUMN_BITMASK;

		if (!_setOriginalTargetFileVersionId) {
			_setOriginalTargetFileVersionId = true;

			_originalTargetFileVersionId = _targetFileVersionId;
		}

		_targetFileVersionId = targetFileVersionId;
	}

	public long getOriginalTargetFileVersionId() {
		return _originalTargetFileVersionId;
	}


	public long getDataFileEntryId() {
		return _dataFileEntryId;
	}


	public void setDataFileEntryId(long dataFileEntryId) {
		_dataFileEntryId = dataFileEntryId;
	}


	public long getSize() {
		return _size;
	}


	public void setSize(long size) {
		_size = size;
	}


	public Date getExpirationDate() {
		return _expirationDate;
	}


	public void setExpirationDate(Date expirationDate) {
		_columnBitmask |= EXPIRATIONDATE_COLUMN_BITMASK;

		if (_originalExpirationDate == null) {
			_originalExpirationDate = _expirationDate;
		}

		_expirationDate = expirationDate;
	}

	public Date getOriginalExpirationDate() {
		return _originalExpirationDate;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}


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


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

		expandoBridge.setAttributes(serviceContext);
	}


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

		return _escapedModel;
	}


	public Object clone() {
		SyncDLFileVersionDiffImpl syncDLFileVersionDiffImpl = new SyncDLFileVersionDiffImpl();

		syncDLFileVersionDiffImpl.setSyncDLFileVersionDiffId(getSyncDLFileVersionDiffId());
		syncDLFileVersionDiffImpl.setFileEntryId(getFileEntryId());
		syncDLFileVersionDiffImpl.setSourceFileVersionId(getSourceFileVersionId());
		syncDLFileVersionDiffImpl.setTargetFileVersionId(getTargetFileVersionId());
		syncDLFileVersionDiffImpl.setDataFileEntryId(getDataFileEntryId());
		syncDLFileVersionDiffImpl.setSize(getSize());
		syncDLFileVersionDiffImpl.setExpirationDate(getExpirationDate());

		syncDLFileVersionDiffImpl.resetOriginalValues();

		return syncDLFileVersionDiffImpl;
	}


	public int compareTo(SyncDLFileVersionDiff syncDLFileVersionDiff) {
		long primaryKey = syncDLFileVersionDiff.getPrimaryKey();

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


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

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

		SyncDLFileVersionDiff syncDLFileVersionDiff = (SyncDLFileVersionDiff)obj;

		long primaryKey = syncDLFileVersionDiff.getPrimaryKey();

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


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


	public void resetOriginalValues() {
		SyncDLFileVersionDiffModelImpl syncDLFileVersionDiffModelImpl = this;

		syncDLFileVersionDiffModelImpl._originalFileEntryId = syncDLFileVersionDiffModelImpl._fileEntryId;

		syncDLFileVersionDiffModelImpl._setOriginalFileEntryId = false;

		syncDLFileVersionDiffModelImpl._originalSourceFileVersionId = syncDLFileVersionDiffModelImpl._sourceFileVersionId;

		syncDLFileVersionDiffModelImpl._setOriginalSourceFileVersionId = false;

		syncDLFileVersionDiffModelImpl._originalTargetFileVersionId = syncDLFileVersionDiffModelImpl._targetFileVersionId;

		syncDLFileVersionDiffModelImpl._setOriginalTargetFileVersionId = false;

		syncDLFileVersionDiffModelImpl._originalExpirationDate = syncDLFileVersionDiffModelImpl._expirationDate;

		syncDLFileVersionDiffModelImpl._columnBitmask = 0;
	}


	public CacheModel<SyncDLFileVersionDiff> toCacheModel() {
		SyncDLFileVersionDiffCacheModel syncDLFileVersionDiffCacheModel = new SyncDLFileVersionDiffCacheModel();

		syncDLFileVersionDiffCacheModel.syncDLFileVersionDiffId = getSyncDLFileVersionDiffId();

		syncDLFileVersionDiffCacheModel.fileEntryId = getFileEntryId();

		syncDLFileVersionDiffCacheModel.sourceFileVersionId = getSourceFileVersionId();

		syncDLFileVersionDiffCacheModel.targetFileVersionId = getTargetFileVersionId();

		syncDLFileVersionDiffCacheModel.dataFileEntryId = getDataFileEntryId();

		syncDLFileVersionDiffCacheModel.size = getSize();

		Date expirationDate = getExpirationDate();

		if (expirationDate != null) {
			syncDLFileVersionDiffCacheModel.expirationDate = expirationDate.getTime();
		}
		else {
			syncDLFileVersionDiffCacheModel.expirationDate = Long.MIN_VALUE;
		}

		return syncDLFileVersionDiffCacheModel;
	}


	public String toString() {
		StringBundler sb = new StringBundler(15);

		sb.append("{syncDLFileVersionDiffId=");
		sb.append(getSyncDLFileVersionDiffId());
		sb.append(", fileEntryId=");
		sb.append(getFileEntryId());
		sb.append(", sourceFileVersionId=");
		sb.append(getSourceFileVersionId());
		sb.append(", targetFileVersionId=");
		sb.append(getTargetFileVersionId());
		sb.append(", dataFileEntryId=");
		sb.append(getDataFileEntryId());
		sb.append(", size=");
		sb.append(getSize());
		sb.append(", expirationDate=");
		sb.append(getExpirationDate());
		sb.append("}");

		return sb.toString();
	}


	public String toXmlString() {
		StringBundler sb = new StringBundler(25);

		sb.append("<model><model-name>");
		sb.append("com.liferay.sync.model.SyncDLFileVersionDiff");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>syncDLFileVersionDiffId</column-name><column-value><![CDATA[");
		sb.append(getSyncDLFileVersionDiffId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>fileEntryId</column-name><column-value><![CDATA[");
		sb.append(getFileEntryId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>sourceFileVersionId</column-name><column-value><![CDATA[");
		sb.append(getSourceFileVersionId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>targetFileVersionId</column-name><column-value><![CDATA[");
		sb.append(getTargetFileVersionId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>dataFileEntryId</column-name><column-value><![CDATA[");
		sb.append(getDataFileEntryId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>size</column-name><column-value><![CDATA[");
		sb.append(getSize());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>expirationDate</column-name><column-value><![CDATA[");
		sb.append(getExpirationDate());
		sb.append("]]></column-value></column>");

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

		return sb.toString();
	}

	private static ClassLoader _classLoader = SyncDLFileVersionDiff.class.getClassLoader();
	private static Class<?>[] _escapedModelInterfaces = new Class[] {
			SyncDLFileVersionDiff.class
		};
	private long _syncDLFileVersionDiffId;
	private long _fileEntryId;
	private long _originalFileEntryId;
	private boolean _setOriginalFileEntryId;
	private long _sourceFileVersionId;
	private long _originalSourceFileVersionId;
	private boolean _setOriginalSourceFileVersionId;
	private long _targetFileVersionId;
	private long _originalTargetFileVersionId;
	private boolean _setOriginalTargetFileVersionId;
	private long _dataFileEntryId;
	private long _size;
	private Date _expirationDate;
	private Date _originalExpirationDate;
	private long _columnBitmask;
	private SyncDLFileVersionDiff _escapedModel;
}