/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of the Liferay Enterprise
 * Subscription License ("License"). You may not use this file except in
 * compliance with the License. You can obtain a copy of the License by
 * contacting Liferay, Inc. See the License for the specific language governing
 * permissions and limitations under the License, including but not limited to
 * distribution rights of the Software.
 *
 *
 *
 */

package com.liferay.portal.model.impl;

import com.liferay.expando.kernel.model.ExpandoBridge;
import com.liferay.expando.kernel.util.ExpandoBridgeFactoryUtil;
import com.liferay.exportimport.kernel.lar.StagedModelType;
import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.LocaleException;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.model.CacheModel;
import com.liferay.portal.kernel.model.Layout;
import com.liferay.portal.kernel.model.LayoutModel;
import com.liferay.portal.kernel.model.LayoutSoap;
import com.liferay.portal.kernel.model.LayoutVersion;
import com.liferay.portal.kernel.model.ModelWrapper;
import com.liferay.portal.kernel.model.User;
import com.liferay.portal.kernel.model.impl.BaseModelImpl;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.UserLocalServiceUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.LocaleUtil;
import com.liferay.portal.kernel.util.LocalizationUtil;
import com.liferay.portal.kernel.util.PortalUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.Validator;

import java.io.Serializable;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;

import java.sql.Blob;
import java.sql.Types;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.function.BiConsumer;
import java.util.function.Function;

/**
 * The base model implementation for the Layout service. Represents a row in the &quot;Layout&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface <code>LayoutModel</code> exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link LayoutImpl}.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see LayoutImpl
 * @generated
 */
@JSON(strict = true)
public class LayoutModelImpl
	extends BaseModelImpl<Layout> implements LayoutModel {

	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a layout model instance should use the <code>Layout</code> interface instead.
	 */
	public static final String TABLE_NAME = "Layout";

	public static final Object[][] TABLE_COLUMNS = {
		{"mvccVersion", Types.BIGINT}, {"uuid_", Types.VARCHAR},
		{"headId", Types.BIGINT}, {"head", Types.BOOLEAN},
		{"plid", Types.BIGINT}, {"groupId", Types.BIGINT},
		{"companyId", Types.BIGINT}, {"userId", Types.BIGINT},
		{"userName", Types.VARCHAR}, {"createDate", Types.TIMESTAMP},
		{"modifiedDate", Types.TIMESTAMP}, {"parentPlid", Types.BIGINT},
		{"privateLayout", Types.BOOLEAN}, {"layoutId", Types.BIGINT},
		{"parentLayoutId", Types.BIGINT}, {"classNameId", Types.BIGINT},
		{"classPK", Types.BIGINT}, {"name", Types.VARCHAR},
		{"title", Types.VARCHAR}, {"description", Types.VARCHAR},
		{"keywords", Types.VARCHAR}, {"robots", Types.VARCHAR},
		{"type_", Types.VARCHAR}, {"typeSettings", Types.CLOB},
		{"hidden_", Types.BOOLEAN}, {"system_", Types.BOOLEAN},
		{"friendlyURL", Types.VARCHAR}, {"iconImageId", Types.BIGINT},
		{"themeId", Types.VARCHAR}, {"colorSchemeId", Types.VARCHAR},
		{"css", Types.CLOB}, {"priority", Types.INTEGER},
		{"layoutPrototypeUuid", Types.VARCHAR},
		{"layoutPrototypeLinkEnabled", Types.BOOLEAN},
		{"sourcePrototypeLayoutUuid", Types.VARCHAR},
		{"publishDate", Types.TIMESTAMP}, {"lastPublishDate", Types.TIMESTAMP}
	};

	public static final Map<String, Integer> TABLE_COLUMNS_MAP =
		new HashMap<String, Integer>();

	static {
		TABLE_COLUMNS_MAP.put("mvccVersion", Types.BIGINT);
		TABLE_COLUMNS_MAP.put("uuid_", Types.VARCHAR);
		TABLE_COLUMNS_MAP.put("headId", Types.BIGINT);
		TABLE_COLUMNS_MAP.put("head", Types.BOOLEAN);
		TABLE_COLUMNS_MAP.put("plid", Types.BIGINT);
		TABLE_COLUMNS_MAP.put("groupId", Types.BIGINT);
		TABLE_COLUMNS_MAP.put("companyId", Types.BIGINT);
		TABLE_COLUMNS_MAP.put("userId", Types.BIGINT);
		TABLE_COLUMNS_MAP.put("userName", Types.VARCHAR);
		TABLE_COLUMNS_MAP.put("createDate", Types.TIMESTAMP);
		TABLE_COLUMNS_MAP.put("modifiedDate", Types.TIMESTAMP);
		TABLE_COLUMNS_MAP.put("parentPlid", Types.BIGINT);
		TABLE_COLUMNS_MAP.put("privateLayout", Types.BOOLEAN);
		TABLE_COLUMNS_MAP.put("layoutId", Types.BIGINT);
		TABLE_COLUMNS_MAP.put("parentLayoutId", Types.BIGINT);
		TABLE_COLUMNS_MAP.put("classNameId", Types.BIGINT);
		TABLE_COLUMNS_MAP.put("classPK", Types.BIGINT);
		TABLE_COLUMNS_MAP.put("name", Types.VARCHAR);
		TABLE_COLUMNS_MAP.put("title", Types.VARCHAR);
		TABLE_COLUMNS_MAP.put("description", Types.VARCHAR);
		TABLE_COLUMNS_MAP.put("keywords", Types.VARCHAR);
		TABLE_COLUMNS_MAP.put("robots", Types.VARCHAR);
		TABLE_COLUMNS_MAP.put("type_", Types.VARCHAR);
		TABLE_COLUMNS_MAP.put("typeSettings", Types.CLOB);
		TABLE_COLUMNS_MAP.put("hidden_", Types.BOOLEAN);
		TABLE_COLUMNS_MAP.put("system_", Types.BOOLEAN);
		TABLE_COLUMNS_MAP.put("friendlyURL", Types.VARCHAR);
		TABLE_COLUMNS_MAP.put("iconImageId", Types.BIGINT);
		TABLE_COLUMNS_MAP.put("themeId", Types.VARCHAR);
		TABLE_COLUMNS_MAP.put("colorSchemeId", Types.VARCHAR);
		TABLE_COLUMNS_MAP.put("css", Types.CLOB);
		TABLE_COLUMNS_MAP.put("priority", Types.INTEGER);
		TABLE_COLUMNS_MAP.put("layoutPrototypeUuid", Types.VARCHAR);
		TABLE_COLUMNS_MAP.put("layoutPrototypeLinkEnabled", Types.BOOLEAN);
		TABLE_COLUMNS_MAP.put("sourcePrototypeLayoutUuid", Types.VARCHAR);
		TABLE_COLUMNS_MAP.put("publishDate", Types.TIMESTAMP);
		TABLE_COLUMNS_MAP.put("lastPublishDate", Types.TIMESTAMP);
	}

	public static final String TABLE_SQL_CREATE =
		"create table Layout (mvccVersion LONG default 0 not null,uuid_ VARCHAR(75) null,headId LONG,head BOOLEAN,plid LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,parentPlid LONG,privateLayout BOOLEAN,layoutId LONG,parentLayoutId LONG,classNameId LONG,classPK LONG,name STRING null,title STRING null,description STRING null,keywords STRING null,robots STRING null,type_ VARCHAR(75) null,typeSettings TEXT null,hidden_ BOOLEAN,system_ BOOLEAN,friendlyURL VARCHAR(255) null,iconImageId LONG,themeId VARCHAR(75) null,colorSchemeId VARCHAR(75) null,css TEXT null,priority INTEGER,layoutPrototypeUuid VARCHAR(75) null,layoutPrototypeLinkEnabled BOOLEAN,sourcePrototypeLayoutUuid VARCHAR(75) null,publishDate DATE null,lastPublishDate DATE null)";

	public static final String TABLE_SQL_DROP = "drop table Layout";

	public static final String ORDER_BY_JPQL =
		" ORDER BY layout.parentLayoutId ASC, layout.priority ASC";

	public static final String ORDER_BY_SQL =
		" ORDER BY Layout.parentLayoutId ASC, Layout.priority 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.portal.util.PropsUtil.get(
			"value.object.entity.cache.enabled.com.liferay.portal.kernel.model.Layout"),
		true);

	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(
		com.liferay.portal.util.PropsUtil.get(
			"value.object.finder.cache.enabled.com.liferay.portal.kernel.model.Layout"),
		true);

	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(
		com.liferay.portal.util.PropsUtil.get(
			"value.object.column.bitmask.enabled.com.liferay.portal.kernel.model.Layout"),
		true);

	public static final long CLASSNAMEID_COLUMN_BITMASK = 1L;

	public static final long CLASSPK_COLUMN_BITMASK = 2L;

	public static final long COMPANYID_COLUMN_BITMASK = 4L;

	public static final long FRIENDLYURL_COLUMN_BITMASK = 8L;

	public static final long GROUPID_COLUMN_BITMASK = 16L;

	public static final long HEAD_COLUMN_BITMASK = 32L;

	public static final long HEADID_COLUMN_BITMASK = 64L;

	public static final long HIDDEN_COLUMN_BITMASK = 128L;

	public static final long ICONIMAGEID_COLUMN_BITMASK = 256L;

	public static final long LAYOUTID_COLUMN_BITMASK = 512L;

	public static final long LAYOUTPROTOTYPEUUID_COLUMN_BITMASK = 1024L;

	public static final long PARENTLAYOUTID_COLUMN_BITMASK = 2048L;

	public static final long PARENTPLID_COLUMN_BITMASK = 4096L;

	public static final long PRIORITY_COLUMN_BITMASK = 8192L;

	public static final long PRIVATELAYOUT_COLUMN_BITMASK = 16384L;

	public static final long SOURCEPROTOTYPELAYOUTUUID_COLUMN_BITMASK = 32768L;

	public static final long SYSTEM_COLUMN_BITMASK = 65536L;

	public static final long TYPE_COLUMN_BITMASK = 131072L;

	public static final long UUID_COLUMN_BITMASK = 262144L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static Layout toModel(LayoutSoap soapModel) {
		if (soapModel == null) {
			return null;
		}

		Layout model = new LayoutImpl();

		model.setMvccVersion(soapModel.getMvccVersion());
		model.setUuid(soapModel.getUuid());
		model.setHeadId(soapModel.getHeadId());
		model.setPlid(soapModel.getPlid());
		model.setGroupId(soapModel.getGroupId());
		model.setCompanyId(soapModel.getCompanyId());
		model.setUserId(soapModel.getUserId());
		model.setUserName(soapModel.getUserName());
		model.setCreateDate(soapModel.getCreateDate());
		model.setModifiedDate(soapModel.getModifiedDate());
		model.setParentPlid(soapModel.getParentPlid());
		model.setPrivateLayout(soapModel.isPrivateLayout());
		model.setLayoutId(soapModel.getLayoutId());
		model.setParentLayoutId(soapModel.getParentLayoutId());
		model.setClassNameId(soapModel.getClassNameId());
		model.setClassPK(soapModel.getClassPK());
		model.setName(soapModel.getName());
		model.setTitle(soapModel.getTitle());
		model.setDescription(soapModel.getDescription());
		model.setKeywords(soapModel.getKeywords());
		model.setRobots(soapModel.getRobots());
		model.setType(soapModel.getType());
		model.setTypeSettings(soapModel.getTypeSettings());
		model.setHidden(soapModel.isHidden());
		model.setSystem(soapModel.isSystem());
		model.setFriendlyURL(soapModel.getFriendlyURL());
		model.setIconImageId(soapModel.getIconImageId());
		model.setThemeId(soapModel.getThemeId());
		model.setColorSchemeId(soapModel.getColorSchemeId());
		model.setCss(soapModel.getCss());
		model.setPriority(soapModel.getPriority());
		model.setLayoutPrototypeUuid(soapModel.getLayoutPrototypeUuid());
		model.setLayoutPrototypeLinkEnabled(
			soapModel.isLayoutPrototypeLinkEnabled());
		model.setSourcePrototypeLayoutUuid(
			soapModel.getSourcePrototypeLayoutUuid());
		model.setPublishDate(soapModel.getPublishDate());
		model.setLastPublishDate(soapModel.getLastPublishDate());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<Layout> toModels(LayoutSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<Layout> models = new ArrayList<Layout>(soapModels.length);

		for (LayoutSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(
		com.liferay.portal.util.PropsUtil.get(
			"lock.expiration.time.com.liferay.portal.kernel.model.Layout"));

	public LayoutModelImpl() {
	}

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

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

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

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

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

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

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

		Map<String, Function<Layout, Object>> attributeGetterFunctions =
			getAttributeGetterFunctions();

		for (Map.Entry<String, Function<Layout, Object>> entry :
				attributeGetterFunctions.entrySet()) {

			String attributeName = entry.getKey();
			Function<Layout, Object> attributeGetterFunction = entry.getValue();

			attributes.put(
				attributeName, attributeGetterFunction.apply((Layout)this));
		}

		attributes.put("entityCacheEnabled", isEntityCacheEnabled());
		attributes.put("finderCacheEnabled", isFinderCacheEnabled());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Map<String, BiConsumer<Layout, Object>> attributeSetterBiConsumers =
			getAttributeSetterBiConsumers();

		for (Map.Entry<String, Object> entry : attributes.entrySet()) {
			String attributeName = entry.getKey();

			BiConsumer<Layout, Object> attributeSetterBiConsumer =
				attributeSetterBiConsumers.get(attributeName);

			if (attributeSetterBiConsumer != null) {
				attributeSetterBiConsumer.accept(
					(Layout)this, entry.getValue());
			}
		}
	}

	public Map<String, Function<Layout, Object>> getAttributeGetterFunctions() {
		return _attributeGetterFunctions;
	}

	public Map<String, BiConsumer<Layout, Object>>
		getAttributeSetterBiConsumers() {

		return _attributeSetterBiConsumers;
	}

	private static Function<InvocationHandler, Layout>
		_getProxyProviderFunction() {

		Class<?> proxyClass = ProxyUtil.getProxyClass(
			Layout.class.getClassLoader(), Layout.class, ModelWrapper.class);

		try {
			Constructor<Layout> constructor =
				(Constructor<Layout>)proxyClass.getConstructor(
					InvocationHandler.class);

			return invocationHandler -> {
				try {
					return constructor.newInstance(invocationHandler);
				}
				catch (ReflectiveOperationException
							reflectiveOperationException) {

					throw new InternalError(reflectiveOperationException);
				}
			};
		}
		catch (NoSuchMethodException noSuchMethodException) {
			throw new InternalError(noSuchMethodException);
		}
	}

	private static final Map<String, Function<Layout, Object>>
		_attributeGetterFunctions;
	private static final Map<String, BiConsumer<Layout, Object>>
		_attributeSetterBiConsumers;

	static {
		Map<String, Function<Layout, Object>> attributeGetterFunctions =
			new LinkedHashMap<String, Function<Layout, Object>>();
		Map<String, BiConsumer<Layout, ?>> attributeSetterBiConsumers =
			new LinkedHashMap<String, BiConsumer<Layout, ?>>();

		attributeGetterFunctions.put("mvccVersion", Layout::getMvccVersion);
		attributeSetterBiConsumers.put(
			"mvccVersion", (BiConsumer<Layout, Long>)Layout::setMvccVersion);
		attributeGetterFunctions.put("uuid", Layout::getUuid);
		attributeSetterBiConsumers.put(
			"uuid", (BiConsumer<Layout, String>)Layout::setUuid);
		attributeGetterFunctions.put("headId", Layout::getHeadId);
		attributeSetterBiConsumers.put(
			"headId", (BiConsumer<Layout, Long>)Layout::setHeadId);
		attributeGetterFunctions.put("plid", Layout::getPlid);
		attributeSetterBiConsumers.put(
			"plid", (BiConsumer<Layout, Long>)Layout::setPlid);
		attributeGetterFunctions.put("groupId", Layout::getGroupId);
		attributeSetterBiConsumers.put(
			"groupId", (BiConsumer<Layout, Long>)Layout::setGroupId);
		attributeGetterFunctions.put("companyId", Layout::getCompanyId);
		attributeSetterBiConsumers.put(
			"companyId", (BiConsumer<Layout, Long>)Layout::setCompanyId);
		attributeGetterFunctions.put("userId", Layout::getUserId);
		attributeSetterBiConsumers.put(
			"userId", (BiConsumer<Layout, Long>)Layout::setUserId);
		attributeGetterFunctions.put("userName", Layout::getUserName);
		attributeSetterBiConsumers.put(
			"userName", (BiConsumer<Layout, String>)Layout::setUserName);
		attributeGetterFunctions.put("createDate", Layout::getCreateDate);
		attributeSetterBiConsumers.put(
			"createDate", (BiConsumer<Layout, Date>)Layout::setCreateDate);
		attributeGetterFunctions.put("modifiedDate", Layout::getModifiedDate);
		attributeSetterBiConsumers.put(
			"modifiedDate", (BiConsumer<Layout, Date>)Layout::setModifiedDate);
		attributeGetterFunctions.put("parentPlid", Layout::getParentPlid);
		attributeSetterBiConsumers.put(
			"parentPlid", (BiConsumer<Layout, Long>)Layout::setParentPlid);
		attributeGetterFunctions.put("privateLayout", Layout::getPrivateLayout);
		attributeSetterBiConsumers.put(
			"privateLayout",
			(BiConsumer<Layout, Boolean>)Layout::setPrivateLayout);
		attributeGetterFunctions.put("layoutId", Layout::getLayoutId);
		attributeSetterBiConsumers.put(
			"layoutId", (BiConsumer<Layout, Long>)Layout::setLayoutId);
		attributeGetterFunctions.put(
			"parentLayoutId", Layout::getParentLayoutId);
		attributeSetterBiConsumers.put(
			"parentLayoutId",
			(BiConsumer<Layout, Long>)Layout::setParentLayoutId);
		attributeGetterFunctions.put("classNameId", Layout::getClassNameId);
		attributeSetterBiConsumers.put(
			"classNameId", (BiConsumer<Layout, Long>)Layout::setClassNameId);
		attributeGetterFunctions.put("classPK", Layout::getClassPK);
		attributeSetterBiConsumers.put(
			"classPK", (BiConsumer<Layout, Long>)Layout::setClassPK);
		attributeGetterFunctions.put("name", Layout::getName);
		attributeSetterBiConsumers.put(
			"name", (BiConsumer<Layout, String>)Layout::setName);
		attributeGetterFunctions.put("title", Layout::getTitle);
		attributeSetterBiConsumers.put(
			"title", (BiConsumer<Layout, String>)Layout::setTitle);
		attributeGetterFunctions.put("description", Layout::getDescription);
		attributeSetterBiConsumers.put(
			"description", (BiConsumer<Layout, String>)Layout::setDescription);
		attributeGetterFunctions.put("keywords", Layout::getKeywords);
		attributeSetterBiConsumers.put(
			"keywords", (BiConsumer<Layout, String>)Layout::setKeywords);
		attributeGetterFunctions.put("robots", Layout::getRobots);
		attributeSetterBiConsumers.put(
			"robots", (BiConsumer<Layout, String>)Layout::setRobots);
		attributeGetterFunctions.put("type", Layout::getType);
		attributeSetterBiConsumers.put(
			"type", (BiConsumer<Layout, String>)Layout::setType);
		attributeGetterFunctions.put("typeSettings", Layout::getTypeSettings);
		attributeSetterBiConsumers.put(
			"typeSettings",
			(BiConsumer<Layout, String>)Layout::setTypeSettings);
		attributeGetterFunctions.put("hidden", Layout::getHidden);
		attributeSetterBiConsumers.put(
			"hidden", (BiConsumer<Layout, Boolean>)Layout::setHidden);
		attributeGetterFunctions.put("system", Layout::getSystem);
		attributeSetterBiConsumers.put(
			"system", (BiConsumer<Layout, Boolean>)Layout::setSystem);
		attributeGetterFunctions.put("friendlyURL", Layout::getFriendlyURL);
		attributeSetterBiConsumers.put(
			"friendlyURL", (BiConsumer<Layout, String>)Layout::setFriendlyURL);
		attributeGetterFunctions.put("iconImageId", Layout::getIconImageId);
		attributeSetterBiConsumers.put(
			"iconImageId", (BiConsumer<Layout, Long>)Layout::setIconImageId);
		attributeGetterFunctions.put("themeId", Layout::getThemeId);
		attributeSetterBiConsumers.put(
			"themeId", (BiConsumer<Layout, String>)Layout::setThemeId);
		attributeGetterFunctions.put("colorSchemeId", Layout::getColorSchemeId);
		attributeSetterBiConsumers.put(
			"colorSchemeId",
			(BiConsumer<Layout, String>)Layout::setColorSchemeId);
		attributeGetterFunctions.put("css", Layout::getCss);
		attributeSetterBiConsumers.put(
			"css", (BiConsumer<Layout, String>)Layout::setCss);
		attributeGetterFunctions.put("priority", Layout::getPriority);
		attributeSetterBiConsumers.put(
			"priority", (BiConsumer<Layout, Integer>)Layout::setPriority);
		attributeGetterFunctions.put(
			"layoutPrototypeUuid", Layout::getLayoutPrototypeUuid);
		attributeSetterBiConsumers.put(
			"layoutPrototypeUuid",
			(BiConsumer<Layout, String>)Layout::setLayoutPrototypeUuid);
		attributeGetterFunctions.put(
			"layoutPrototypeLinkEnabled",
			Layout::getLayoutPrototypeLinkEnabled);
		attributeSetterBiConsumers.put(
			"layoutPrototypeLinkEnabled",
			(BiConsumer<Layout, Boolean>)Layout::setLayoutPrototypeLinkEnabled);
		attributeGetterFunctions.put(
			"sourcePrototypeLayoutUuid", Layout::getSourcePrototypeLayoutUuid);
		attributeSetterBiConsumers.put(
			"sourcePrototypeLayoutUuid",
			(BiConsumer<Layout, String>)Layout::setSourcePrototypeLayoutUuid);
		attributeGetterFunctions.put("publishDate", Layout::getPublishDate);
		attributeSetterBiConsumers.put(
			"publishDate", (BiConsumer<Layout, Date>)Layout::setPublishDate);
		attributeGetterFunctions.put(
			"lastPublishDate", Layout::getLastPublishDate);
		attributeSetterBiConsumers.put(
			"lastPublishDate",
			(BiConsumer<Layout, Date>)Layout::setLastPublishDate);

		_attributeGetterFunctions = Collections.unmodifiableMap(
			attributeGetterFunctions);
		_attributeSetterBiConsumers = Collections.unmodifiableMap(
			(Map)attributeSetterBiConsumers);
	}

	@Override
	public void populateVersionModel(LayoutVersion layoutVersion) {
		layoutVersion.setUuid(getUuid());
		layoutVersion.setGroupId(getGroupId());
		layoutVersion.setCompanyId(getCompanyId());
		layoutVersion.setUserId(getUserId());
		layoutVersion.setUserName(getUserName());
		layoutVersion.setCreateDate(getCreateDate());
		layoutVersion.setModifiedDate(getModifiedDate());
		layoutVersion.setParentPlid(getParentPlid());
		layoutVersion.setPrivateLayout(getPrivateLayout());
		layoutVersion.setLayoutId(getLayoutId());
		layoutVersion.setParentLayoutId(getParentLayoutId());
		layoutVersion.setClassNameId(getClassNameId());
		layoutVersion.setClassPK(getClassPK());
		layoutVersion.setName(getName());
		layoutVersion.setTitle(getTitle());
		layoutVersion.setDescription(getDescription());
		layoutVersion.setKeywords(getKeywords());
		layoutVersion.setRobots(getRobots());
		layoutVersion.setType(getType());
		layoutVersion.setTypeSettings(getTypeSettings());
		layoutVersion.setHidden(getHidden());
		layoutVersion.setSystem(getSystem());
		layoutVersion.setFriendlyURL(getFriendlyURL());
		layoutVersion.setIconImageId(getIconImageId());
		layoutVersion.setThemeId(getThemeId());
		layoutVersion.setColorSchemeId(getColorSchemeId());
		layoutVersion.setCss(getCss());
		layoutVersion.setPriority(getPriority());
		layoutVersion.setLayoutPrototypeUuid(getLayoutPrototypeUuid());
		layoutVersion.setLayoutPrototypeLinkEnabled(
			getLayoutPrototypeLinkEnabled());
		layoutVersion.setSourcePrototypeLayoutUuid(
			getSourcePrototypeLayoutUuid());
		layoutVersion.setPublishDate(getPublishDate());
		layoutVersion.setLastPublishDate(getLastPublishDate());
	}

	@JSON
	@Override
	public long getMvccVersion() {
		return _mvccVersion;
	}

	@Override
	public void setMvccVersion(long mvccVersion) {
		_mvccVersion = mvccVersion;
	}

	@JSON
	@Override
	public String getUuid() {
		if (_uuid == null) {
			return "";
		}
		else {
			return _uuid;
		}
	}

	@Override
	public void setUuid(String uuid) {
		_columnBitmask |= UUID_COLUMN_BITMASK;

		if (_originalUuid == null) {
			_originalUuid = _uuid;
		}

		_uuid = uuid;
	}

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

	@JSON
	@Override
	public long getHeadId() {
		return _headId;
	}

	@Override
	public void setHeadId(long headId) {
		_columnBitmask |= HEADID_COLUMN_BITMASK;

		if (!_setOriginalHeadId) {
			_setOriginalHeadId = true;

			_originalHeadId = _headId;
		}

		if (headId >= 0) {
			setHead(false);
		}
		else {
			setHead(true);
		}

		_headId = headId;
	}

	public long getOriginalHeadId() {
		return _originalHeadId;
	}

	@JSON(include = false)
	public boolean getHead() {
		return _head;
	}

	@Override
	public boolean isHead() {
		return _head;
	}

	public void setHead(boolean head) {
		_columnBitmask |= HEAD_COLUMN_BITMASK;

		if (!_setOriginalHead) {
			_setOriginalHead = true;

			_originalHead = _head;
		}

		_head = head;
	}

	public boolean getOriginalHead() {
		return _originalHead;
	}

	@JSON
	@Override
	public long getPlid() {
		return _plid;
	}

	@Override
	public void setPlid(long plid) {
		_plid = plid;
	}

	@JSON
	@Override
	public long getGroupId() {
		return _groupId;
	}

	@Override
	public void setGroupId(long groupId) {
		_columnBitmask |= GROUPID_COLUMN_BITMASK;

		if (!_setOriginalGroupId) {
			_setOriginalGroupId = true;

			_originalGroupId = _groupId;
		}

		_groupId = groupId;
	}

	public long getOriginalGroupId() {
		return _originalGroupId;
	}

	@JSON
	@Override
	public long getCompanyId() {
		return _companyId;
	}

	@Override
	public void setCompanyId(long companyId) {
		_columnBitmask |= COMPANYID_COLUMN_BITMASK;

		if (!_setOriginalCompanyId) {
			_setOriginalCompanyId = true;

			_originalCompanyId = _companyId;
		}

		_companyId = companyId;
	}

	public long getOriginalCompanyId() {
		return _originalCompanyId;
	}

	@JSON
	@Override
	public long getUserId() {
		return _userId;
	}

	@Override
	public void setUserId(long userId) {
		_userId = userId;
	}

	@Override
	public String getUserUuid() {
		try {
			User user = UserLocalServiceUtil.getUserById(getUserId());

			return user.getUuid();
		}
		catch (PortalException portalException) {
			return "";
		}
	}

	@Override
	public void setUserUuid(String userUuid) {
	}

	@JSON
	@Override
	public String getUserName() {
		if (_userName == null) {
			return "";
		}
		else {
			return _userName;
		}
	}

	@Override
	public void setUserName(String userName) {
		_userName = userName;
	}

	@JSON
	@Override
	public Date getCreateDate() {
		return _createDate;
	}

	@Override
	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	@JSON
	@Override
	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public boolean hasSetModifiedDate() {
		return _setModifiedDate;
	}

	@Override
	public void setModifiedDate(Date modifiedDate) {
		_setModifiedDate = true;

		_modifiedDate = modifiedDate;
	}

	@JSON
	@Override
	public long getParentPlid() {
		return _parentPlid;
	}

	@Override
	public void setParentPlid(long parentPlid) {
		_columnBitmask |= PARENTPLID_COLUMN_BITMASK;

		if (!_setOriginalParentPlid) {
			_setOriginalParentPlid = true;

			_originalParentPlid = _parentPlid;
		}

		_parentPlid = parentPlid;
	}

	public long getOriginalParentPlid() {
		return _originalParentPlid;
	}

	@JSON
	@Override
	public boolean getPrivateLayout() {
		return _privateLayout;
	}

	@JSON
	@Override
	public boolean isPrivateLayout() {
		return _privateLayout;
	}

	@Override
	public void setPrivateLayout(boolean privateLayout) {
		_columnBitmask |= PRIVATELAYOUT_COLUMN_BITMASK;

		if (!_setOriginalPrivateLayout) {
			_setOriginalPrivateLayout = true;

			_originalPrivateLayout = _privateLayout;
		}

		_privateLayout = privateLayout;
	}

	public boolean getOriginalPrivateLayout() {
		return _originalPrivateLayout;
	}

	@JSON
	@Override
	public long getLayoutId() {
		return _layoutId;
	}

	@Override
	public void setLayoutId(long layoutId) {
		_columnBitmask |= LAYOUTID_COLUMN_BITMASK;

		if (!_setOriginalLayoutId) {
			_setOriginalLayoutId = true;

			_originalLayoutId = _layoutId;
		}

		_layoutId = layoutId;
	}

	public long getOriginalLayoutId() {
		return _originalLayoutId;
	}

	@JSON
	@Override
	public long getParentLayoutId() {
		return _parentLayoutId;
	}

	@Override
	public void setParentLayoutId(long parentLayoutId) {
		_columnBitmask = -1L;

		if (!_setOriginalParentLayoutId) {
			_setOriginalParentLayoutId = true;

			_originalParentLayoutId = _parentLayoutId;
		}

		_parentLayoutId = parentLayoutId;
	}

	public long getOriginalParentLayoutId() {
		return _originalParentLayoutId;
	}

	@Override
	public String getClassName() {
		if (getClassNameId() <= 0) {
			return "";
		}

		return PortalUtil.getClassName(getClassNameId());
	}

	@Override
	public void setClassName(String className) {
		long classNameId = 0;

		if (Validator.isNotNull(className)) {
			classNameId = PortalUtil.getClassNameId(className);
		}

		setClassNameId(classNameId);
	}

	@JSON
	@Override
	public long getClassNameId() {
		return _classNameId;
	}

	@Override
	public void setClassNameId(long classNameId) {
		_columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;

		if (!_setOriginalClassNameId) {
			_setOriginalClassNameId = true;

			_originalClassNameId = _classNameId;
		}

		_classNameId = classNameId;
	}

	public long getOriginalClassNameId() {
		return _originalClassNameId;
	}

	@JSON
	@Override
	public long getClassPK() {
		return _classPK;
	}

	@Override
	public void setClassPK(long classPK) {
		_columnBitmask |= CLASSPK_COLUMN_BITMASK;

		if (!_setOriginalClassPK) {
			_setOriginalClassPK = true;

			_originalClassPK = _classPK;
		}

		_classPK = classPK;
	}

	public long getOriginalClassPK() {
		return _originalClassPK;
	}

	@JSON
	@Override
	public String getName() {
		if (_name == null) {
			return "";
		}
		else {
			return _name;
		}
	}

	@Override
	public String getName(Locale locale) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getName(languageId);
	}

	@Override
	public String getName(Locale locale, boolean useDefault) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getName(languageId, useDefault);
	}

	@Override
	public String getName(String languageId) {
		return LocalizationUtil.getLocalization(getName(), languageId);
	}

	@Override
	public String getName(String languageId, boolean useDefault) {
		return LocalizationUtil.getLocalization(
			getName(), languageId, useDefault);
	}

	@Override
	public String getNameCurrentLanguageId() {
		return _nameCurrentLanguageId;
	}

	@JSON
	@Override
	public String getNameCurrentValue() {
		Locale locale = getLocale(_nameCurrentLanguageId);

		return getName(locale);
	}

	@Override
	public Map<Locale, String> getNameMap() {
		return LocalizationUtil.getLocalizationMap(getName());
	}

	@Override
	public void setName(String name) {
		_name = name;
	}

	@Override
	public void setName(String name, Locale locale) {
		setName(name, locale, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setName(String name, Locale locale, Locale defaultLocale) {
		String languageId = LocaleUtil.toLanguageId(locale);
		String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

		if (Validator.isNotNull(name)) {
			setName(
				LocalizationUtil.updateLocalization(
					getName(), "Name", name, languageId, defaultLanguageId));
		}
		else {
			setName(
				LocalizationUtil.removeLocalization(
					getName(), "Name", languageId));
		}
	}

	@Override
	public void setNameCurrentLanguageId(String languageId) {
		_nameCurrentLanguageId = languageId;
	}

	@Override
	public void setNameMap(Map<Locale, String> nameMap) {
		setNameMap(nameMap, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setNameMap(Map<Locale, String> nameMap, Locale defaultLocale) {
		if (nameMap == null) {
			return;
		}

		setName(
			LocalizationUtil.updateLocalization(
				nameMap, getName(), "Name",
				LocaleUtil.toLanguageId(defaultLocale)));
	}

	@JSON
	@Override
	public String getTitle() {
		if (_title == null) {
			return "";
		}
		else {
			return _title;
		}
	}

	@Override
	public String getTitle(Locale locale) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getTitle(languageId);
	}

	@Override
	public String getTitle(Locale locale, boolean useDefault) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getTitle(languageId, useDefault);
	}

	@Override
	public String getTitle(String languageId) {
		return LocalizationUtil.getLocalization(getTitle(), languageId);
	}

	@Override
	public String getTitle(String languageId, boolean useDefault) {
		return LocalizationUtil.getLocalization(
			getTitle(), languageId, useDefault);
	}

	@Override
	public String getTitleCurrentLanguageId() {
		return _titleCurrentLanguageId;
	}

	@JSON
	@Override
	public String getTitleCurrentValue() {
		Locale locale = getLocale(_titleCurrentLanguageId);

		return getTitle(locale);
	}

	@Override
	public Map<Locale, String> getTitleMap() {
		return LocalizationUtil.getLocalizationMap(getTitle());
	}

	@Override
	public void setTitle(String title) {
		_title = title;
	}

	@Override
	public void setTitle(String title, Locale locale) {
		setTitle(title, locale, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setTitle(String title, Locale locale, Locale defaultLocale) {
		String languageId = LocaleUtil.toLanguageId(locale);
		String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

		if (Validator.isNotNull(title)) {
			setTitle(
				LocalizationUtil.updateLocalization(
					getTitle(), "Title", title, languageId, defaultLanguageId));
		}
		else {
			setTitle(
				LocalizationUtil.removeLocalization(
					getTitle(), "Title", languageId));
		}
	}

	@Override
	public void setTitleCurrentLanguageId(String languageId) {
		_titleCurrentLanguageId = languageId;
	}

	@Override
	public void setTitleMap(Map<Locale, String> titleMap) {
		setTitleMap(titleMap, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setTitleMap(
		Map<Locale, String> titleMap, Locale defaultLocale) {

		if (titleMap == null) {
			return;
		}

		setTitle(
			LocalizationUtil.updateLocalization(
				titleMap, getTitle(), "Title",
				LocaleUtil.toLanguageId(defaultLocale)));
	}

	@JSON
	@Override
	public String getDescription() {
		if (_description == null) {
			return "";
		}
		else {
			return _description;
		}
	}

	@Override
	public String getDescription(Locale locale) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getDescription(languageId);
	}

	@Override
	public String getDescription(Locale locale, boolean useDefault) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getDescription(languageId, useDefault);
	}

	@Override
	public String getDescription(String languageId) {
		return LocalizationUtil.getLocalization(getDescription(), languageId);
	}

	@Override
	public String getDescription(String languageId, boolean useDefault) {
		return LocalizationUtil.getLocalization(
			getDescription(), languageId, useDefault);
	}

	@Override
	public String getDescriptionCurrentLanguageId() {
		return _descriptionCurrentLanguageId;
	}

	@JSON
	@Override
	public String getDescriptionCurrentValue() {
		Locale locale = getLocale(_descriptionCurrentLanguageId);

		return getDescription(locale);
	}

	@Override
	public Map<Locale, String> getDescriptionMap() {
		return LocalizationUtil.getLocalizationMap(getDescription());
	}

	@Override
	public void setDescription(String description) {
		_description = description;
	}

	@Override
	public void setDescription(String description, Locale locale) {
		setDescription(description, locale, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setDescription(
		String description, Locale locale, Locale defaultLocale) {

		String languageId = LocaleUtil.toLanguageId(locale);
		String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

		if (Validator.isNotNull(description)) {
			setDescription(
				LocalizationUtil.updateLocalization(
					getDescription(), "Description", description, languageId,
					defaultLanguageId));
		}
		else {
			setDescription(
				LocalizationUtil.removeLocalization(
					getDescription(), "Description", languageId));
		}
	}

	@Override
	public void setDescriptionCurrentLanguageId(String languageId) {
		_descriptionCurrentLanguageId = languageId;
	}

	@Override
	public void setDescriptionMap(Map<Locale, String> descriptionMap) {
		setDescriptionMap(descriptionMap, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setDescriptionMap(
		Map<Locale, String> descriptionMap, Locale defaultLocale) {

		if (descriptionMap == null) {
			return;
		}

		setDescription(
			LocalizationUtil.updateLocalization(
				descriptionMap, getDescription(), "Description",
				LocaleUtil.toLanguageId(defaultLocale)));
	}

	@JSON
	@Override
	public String getKeywords() {
		if (_keywords == null) {
			return "";
		}
		else {
			return _keywords;
		}
	}

	@Override
	public String getKeywords(Locale locale) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getKeywords(languageId);
	}

	@Override
	public String getKeywords(Locale locale, boolean useDefault) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getKeywords(languageId, useDefault);
	}

	@Override
	public String getKeywords(String languageId) {
		return LocalizationUtil.getLocalization(getKeywords(), languageId);
	}

	@Override
	public String getKeywords(String languageId, boolean useDefault) {
		return LocalizationUtil.getLocalization(
			getKeywords(), languageId, useDefault);
	}

	@Override
	public String getKeywordsCurrentLanguageId() {
		return _keywordsCurrentLanguageId;
	}

	@JSON
	@Override
	public String getKeywordsCurrentValue() {
		Locale locale = getLocale(_keywordsCurrentLanguageId);

		return getKeywords(locale);
	}

	@Override
	public Map<Locale, String> getKeywordsMap() {
		return LocalizationUtil.getLocalizationMap(getKeywords());
	}

	@Override
	public void setKeywords(String keywords) {
		_keywords = keywords;
	}

	@Override
	public void setKeywords(String keywords, Locale locale) {
		setKeywords(keywords, locale, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setKeywords(
		String keywords, Locale locale, Locale defaultLocale) {

		String languageId = LocaleUtil.toLanguageId(locale);
		String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

		if (Validator.isNotNull(keywords)) {
			setKeywords(
				LocalizationUtil.updateLocalization(
					getKeywords(), "Keywords", keywords, languageId,
					defaultLanguageId));
		}
		else {
			setKeywords(
				LocalizationUtil.removeLocalization(
					getKeywords(), "Keywords", languageId));
		}
	}

	@Override
	public void setKeywordsCurrentLanguageId(String languageId) {
		_keywordsCurrentLanguageId = languageId;
	}

	@Override
	public void setKeywordsMap(Map<Locale, String> keywordsMap) {
		setKeywordsMap(keywordsMap, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setKeywordsMap(
		Map<Locale, String> keywordsMap, Locale defaultLocale) {

		if (keywordsMap == null) {
			return;
		}

		setKeywords(
			LocalizationUtil.updateLocalization(
				keywordsMap, getKeywords(), "Keywords",
				LocaleUtil.toLanguageId(defaultLocale)));
	}

	@JSON
	@Override
	public String getRobots() {
		if (_robots == null) {
			return "";
		}
		else {
			return _robots;
		}
	}

	@Override
	public String getRobots(Locale locale) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getRobots(languageId);
	}

	@Override
	public String getRobots(Locale locale, boolean useDefault) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getRobots(languageId, useDefault);
	}

	@Override
	public String getRobots(String languageId) {
		return LocalizationUtil.getLocalization(getRobots(), languageId);
	}

	@Override
	public String getRobots(String languageId, boolean useDefault) {
		return LocalizationUtil.getLocalization(
			getRobots(), languageId, useDefault);
	}

	@Override
	public String getRobotsCurrentLanguageId() {
		return _robotsCurrentLanguageId;
	}

	@JSON
	@Override
	public String getRobotsCurrentValue() {
		Locale locale = getLocale(_robotsCurrentLanguageId);

		return getRobots(locale);
	}

	@Override
	public Map<Locale, String> getRobotsMap() {
		return LocalizationUtil.getLocalizationMap(getRobots());
	}

	@Override
	public void setRobots(String robots) {
		_robots = robots;
	}

	@Override
	public void setRobots(String robots, Locale locale) {
		setRobots(robots, locale, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setRobots(String robots, Locale locale, Locale defaultLocale) {
		String languageId = LocaleUtil.toLanguageId(locale);
		String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

		if (Validator.isNotNull(robots)) {
			setRobots(
				LocalizationUtil.updateLocalization(
					getRobots(), "Robots", robots, languageId,
					defaultLanguageId));
		}
		else {
			setRobots(
				LocalizationUtil.removeLocalization(
					getRobots(), "Robots", languageId));
		}
	}

	@Override
	public void setRobotsCurrentLanguageId(String languageId) {
		_robotsCurrentLanguageId = languageId;
	}

	@Override
	public void setRobotsMap(Map<Locale, String> robotsMap) {
		setRobotsMap(robotsMap, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setRobotsMap(
		Map<Locale, String> robotsMap, Locale defaultLocale) {

		if (robotsMap == null) {
			return;
		}

		setRobots(
			LocalizationUtil.updateLocalization(
				robotsMap, getRobots(), "Robots",
				LocaleUtil.toLanguageId(defaultLocale)));
	}

	@JSON
	@Override
	public String getType() {
		if (_type == null) {
			return "";
		}
		else {
			return _type;
		}
	}

	@Override
	public void setType(String type) {
		_columnBitmask |= TYPE_COLUMN_BITMASK;

		if (_originalType == null) {
			_originalType = _type;
		}

		_type = type;
	}

	public String getOriginalType() {
		return GetterUtil.getString(_originalType);
	}

	@JSON
	@Override
	public String getTypeSettings() {
		if (_typeSettings == null) {
			return "";
		}
		else {
			return _typeSettings;
		}
	}

	@Override
	public void setTypeSettings(String typeSettings) {
		_typeSettings = typeSettings;
	}

	@JSON
	@Override
	public boolean getHidden() {
		return _hidden;
	}

	@JSON
	@Override
	public boolean isHidden() {
		return _hidden;
	}

	@Override
	public void setHidden(boolean hidden) {
		_columnBitmask |= HIDDEN_COLUMN_BITMASK;

		if (!_setOriginalHidden) {
			_setOriginalHidden = true;

			_originalHidden = _hidden;
		}

		_hidden = hidden;
	}

	public boolean getOriginalHidden() {
		return _originalHidden;
	}

	@JSON
	@Override
	public boolean getSystem() {
		return _system;
	}

	@JSON
	@Override
	public boolean isSystem() {
		return _system;
	}

	@Override
	public void setSystem(boolean system) {
		_columnBitmask |= SYSTEM_COLUMN_BITMASK;

		if (!_setOriginalSystem) {
			_setOriginalSystem = true;

			_originalSystem = _system;
		}

		_system = system;
	}

	public boolean getOriginalSystem() {
		return _originalSystem;
	}

	@JSON
	@Override
	public String getFriendlyURL() {
		if (_friendlyURL == null) {
			return "";
		}
		else {
			return _friendlyURL;
		}
	}

	@Override
	public void setFriendlyURL(String friendlyURL) {
		_columnBitmask |= FRIENDLYURL_COLUMN_BITMASK;

		if (_originalFriendlyURL == null) {
			_originalFriendlyURL = _friendlyURL;
		}

		_friendlyURL = friendlyURL;
	}

	public String getOriginalFriendlyURL() {
		return GetterUtil.getString(_originalFriendlyURL);
	}

	@JSON
	@Override
	public long getIconImageId() {
		return _iconImageId;
	}

	@Override
	public void setIconImageId(long iconImageId) {
		_columnBitmask |= ICONIMAGEID_COLUMN_BITMASK;

		if (!_setOriginalIconImageId) {
			_setOriginalIconImageId = true;

			_originalIconImageId = _iconImageId;
		}

		_iconImageId = iconImageId;
	}

	public long getOriginalIconImageId() {
		return _originalIconImageId;
	}

	@JSON
	@Override
	public String getThemeId() {
		if (_themeId == null) {
			return "";
		}
		else {
			return _themeId;
		}
	}

	@Override
	public void setThemeId(String themeId) {
		_themeId = themeId;
	}

	@JSON
	@Override
	public String getColorSchemeId() {
		if (_colorSchemeId == null) {
			return "";
		}
		else {
			return _colorSchemeId;
		}
	}

	@Override
	public void setColorSchemeId(String colorSchemeId) {
		_colorSchemeId = colorSchemeId;
	}

	@JSON
	@Override
	public String getCss() {
		if (_css == null) {
			return "";
		}
		else {
			return _css;
		}
	}

	@Override
	public void setCss(String css) {
		_css = css;
	}

	@JSON
	@Override
	public int getPriority() {
		return _priority;
	}

	@Override
	public void setPriority(int priority) {
		_columnBitmask = -1L;

		if (!_setOriginalPriority) {
			_setOriginalPriority = true;

			_originalPriority = _priority;
		}

		_priority = priority;
	}

	public int getOriginalPriority() {
		return _originalPriority;
	}

	@JSON
	@Override
	public String getLayoutPrototypeUuid() {
		if (_layoutPrototypeUuid == null) {
			return "";
		}
		else {
			return _layoutPrototypeUuid;
		}
	}

	@Override
	public void setLayoutPrototypeUuid(String layoutPrototypeUuid) {
		_columnBitmask |= LAYOUTPROTOTYPEUUID_COLUMN_BITMASK;

		if (_originalLayoutPrototypeUuid == null) {
			_originalLayoutPrototypeUuid = _layoutPrototypeUuid;
		}

		_layoutPrototypeUuid = layoutPrototypeUuid;
	}

	public String getOriginalLayoutPrototypeUuid() {
		return GetterUtil.getString(_originalLayoutPrototypeUuid);
	}

	@JSON
	@Override
	public boolean getLayoutPrototypeLinkEnabled() {
		return _layoutPrototypeLinkEnabled;
	}

	@JSON
	@Override
	public boolean isLayoutPrototypeLinkEnabled() {
		return _layoutPrototypeLinkEnabled;
	}

	@Override
	public void setLayoutPrototypeLinkEnabled(
		boolean layoutPrototypeLinkEnabled) {

		_layoutPrototypeLinkEnabled = layoutPrototypeLinkEnabled;
	}

	@JSON
	@Override
	public String getSourcePrototypeLayoutUuid() {
		if (_sourcePrototypeLayoutUuid == null) {
			return "";
		}
		else {
			return _sourcePrototypeLayoutUuid;
		}
	}

	@Override
	public void setSourcePrototypeLayoutUuid(String sourcePrototypeLayoutUuid) {
		_columnBitmask |= SOURCEPROTOTYPELAYOUTUUID_COLUMN_BITMASK;

		if (_originalSourcePrototypeLayoutUuid == null) {
			_originalSourcePrototypeLayoutUuid = _sourcePrototypeLayoutUuid;
		}

		_sourcePrototypeLayoutUuid = sourcePrototypeLayoutUuid;
	}

	public String getOriginalSourcePrototypeLayoutUuid() {
		return GetterUtil.getString(_originalSourcePrototypeLayoutUuid);
	}

	@JSON
	@Override
	public Date getPublishDate() {
		return _publishDate;
	}

	@Override
	public void setPublishDate(Date publishDate) {
		_publishDate = publishDate;
	}

	@JSON
	@Override
	public Date getLastPublishDate() {
		return _lastPublishDate;
	}

	@Override
	public void setLastPublishDate(Date lastPublishDate) {
		_lastPublishDate = lastPublishDate;
	}

	@Override
	public StagedModelType getStagedModelType() {
		return new StagedModelType(
			PortalUtil.getClassNameId(Layout.class.getName()),
			getClassNameId());
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

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

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

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public String[] getAvailableLanguageIds() {
		Set<String> availableLanguageIds = new TreeSet<String>();

		Map<Locale, String> nameMap = getNameMap();

		for (Map.Entry<Locale, String> entry : nameMap.entrySet()) {
			Locale locale = entry.getKey();
			String value = entry.getValue();

			if (Validator.isNotNull(value)) {
				availableLanguageIds.add(LocaleUtil.toLanguageId(locale));
			}
		}

		Map<Locale, String> titleMap = getTitleMap();

		for (Map.Entry<Locale, String> entry : titleMap.entrySet()) {
			Locale locale = entry.getKey();
			String value = entry.getValue();

			if (Validator.isNotNull(value)) {
				availableLanguageIds.add(LocaleUtil.toLanguageId(locale));
			}
		}

		Map<Locale, String> descriptionMap = getDescriptionMap();

		for (Map.Entry<Locale, String> entry : descriptionMap.entrySet()) {
			Locale locale = entry.getKey();
			String value = entry.getValue();

			if (Validator.isNotNull(value)) {
				availableLanguageIds.add(LocaleUtil.toLanguageId(locale));
			}
		}

		Map<Locale, String> keywordsMap = getKeywordsMap();

		for (Map.Entry<Locale, String> entry : keywordsMap.entrySet()) {
			Locale locale = entry.getKey();
			String value = entry.getValue();

			if (Validator.isNotNull(value)) {
				availableLanguageIds.add(LocaleUtil.toLanguageId(locale));
			}
		}

		Map<Locale, String> robotsMap = getRobotsMap();

		for (Map.Entry<Locale, String> entry : robotsMap.entrySet()) {
			Locale locale = entry.getKey();
			String value = entry.getValue();

			if (Validator.isNotNull(value)) {
				availableLanguageIds.add(LocaleUtil.toLanguageId(locale));
			}
		}

		return availableLanguageIds.toArray(
			new String[availableLanguageIds.size()]);
	}

	@Override
	public String getDefaultLanguageId() {
		String xml = getName();

		if (xml == null) {
			return "";
		}

		Locale defaultLocale = LocaleUtil.getSiteDefault();

		return LocalizationUtil.getDefaultLanguageId(xml, defaultLocale);
	}

	@Override
	public void prepareLocalizedFieldsForImport() throws LocaleException {
		Locale defaultLocale = LocaleUtil.fromLanguageId(
			getDefaultLanguageId());

		Locale[] availableLocales = LocaleUtil.fromLanguageIds(
			getAvailableLanguageIds());

		Locale defaultImportLocale = LocalizationUtil.getDefaultImportLocale(
			Layout.class.getName(), getPrimaryKey(), defaultLocale,
			availableLocales);

		prepareLocalizedFieldsForImport(defaultImportLocale);
	}

	@Override
	@SuppressWarnings("unused")
	public void prepareLocalizedFieldsForImport(Locale defaultImportLocale)
		throws LocaleException {

		Locale defaultLocale = LocaleUtil.getSiteDefault();

		String modelDefaultLanguageId = getDefaultLanguageId();

		String name = getName(defaultLocale);

		if (Validator.isNull(name)) {
			setName(getName(modelDefaultLanguageId), defaultLocale);
		}
		else {
			setName(getName(defaultLocale), defaultLocale, defaultLocale);
		}

		String title = getTitle(defaultLocale);

		if (Validator.isNull(title)) {
			setTitle(getTitle(modelDefaultLanguageId), defaultLocale);
		}
		else {
			setTitle(getTitle(defaultLocale), defaultLocale, defaultLocale);
		}

		String description = getDescription(defaultLocale);

		if (Validator.isNull(description)) {
			setDescription(
				getDescription(modelDefaultLanguageId), defaultLocale);
		}
		else {
			setDescription(
				getDescription(defaultLocale), defaultLocale, defaultLocale);
		}

		String keywords = getKeywords(defaultLocale);

		if (Validator.isNull(keywords)) {
			setKeywords(getKeywords(modelDefaultLanguageId), defaultLocale);
		}
		else {
			setKeywords(
				getKeywords(defaultLocale), defaultLocale, defaultLocale);
		}

		String robots = getRobots(defaultLocale);

		if (Validator.isNull(robots)) {
			setRobots(getRobots(modelDefaultLanguageId), defaultLocale);
		}
		else {
			setRobots(getRobots(defaultLocale), defaultLocale, defaultLocale);
		}
	}

	@Override
	public Layout toEscapedModel() {
		if (_escapedModel == null) {
			Function<InvocationHandler, Layout>
				escapedModelProxyProviderFunction =
					EscapedModelProxyProviderFunctionHolder.
						_escapedModelProxyProviderFunction;

			_escapedModel = escapedModelProxyProviderFunction.apply(
				new AutoEscapeBeanHandler(this));
		}

		return _escapedModel;
	}

	@Override
	public Object clone() {
		LayoutImpl layoutImpl = new LayoutImpl();

		layoutImpl.setMvccVersion(getMvccVersion());
		layoutImpl.setUuid(getUuid());
		layoutImpl.setHeadId(getHeadId());
		layoutImpl.setPlid(getPlid());
		layoutImpl.setGroupId(getGroupId());
		layoutImpl.setCompanyId(getCompanyId());
		layoutImpl.setUserId(getUserId());
		layoutImpl.setUserName(getUserName());
		layoutImpl.setCreateDate(getCreateDate());
		layoutImpl.setModifiedDate(getModifiedDate());
		layoutImpl.setParentPlid(getParentPlid());
		layoutImpl.setPrivateLayout(isPrivateLayout());
		layoutImpl.setLayoutId(getLayoutId());
		layoutImpl.setParentLayoutId(getParentLayoutId());
		layoutImpl.setClassNameId(getClassNameId());
		layoutImpl.setClassPK(getClassPK());
		layoutImpl.setName(getName());
		layoutImpl.setTitle(getTitle());
		layoutImpl.setDescription(getDescription());
		layoutImpl.setKeywords(getKeywords());
		layoutImpl.setRobots(getRobots());
		layoutImpl.setType(getType());
		layoutImpl.setTypeSettings(getTypeSettings());
		layoutImpl.setHidden(isHidden());
		layoutImpl.setSystem(isSystem());
		layoutImpl.setFriendlyURL(getFriendlyURL());
		layoutImpl.setIconImageId(getIconImageId());
		layoutImpl.setThemeId(getThemeId());
		layoutImpl.setColorSchemeId(getColorSchemeId());
		layoutImpl.setCss(getCss());
		layoutImpl.setPriority(getPriority());
		layoutImpl.setLayoutPrototypeUuid(getLayoutPrototypeUuid());
		layoutImpl.setLayoutPrototypeLinkEnabled(
			isLayoutPrototypeLinkEnabled());
		layoutImpl.setSourcePrototypeLayoutUuid(getSourcePrototypeLayoutUuid());
		layoutImpl.setPublishDate(getPublishDate());
		layoutImpl.setLastPublishDate(getLastPublishDate());

		layoutImpl.resetOriginalValues();

		return layoutImpl;
	}

	@Override
	public int compareTo(Layout layout) {
		int value = 0;

		if (getParentLayoutId() < layout.getParentLayoutId()) {
			value = -1;
		}
		else if (getParentLayoutId() > layout.getParentLayoutId()) {
			value = 1;
		}
		else {
			value = 0;
		}

		if (value != 0) {
			return value;
		}

		if (getPriority() < layout.getPriority()) {
			value = -1;
		}
		else if (getPriority() > layout.getPriority()) {
			value = 1;
		}
		else {
			value = 0;
		}

		if (value != 0) {
			return value;
		}

		return 0;
	}

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

		if (!(object instanceof Layout)) {
			return false;
		}

		Layout layout = (Layout)object;

		long primaryKey = layout.getPrimaryKey();

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

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

	@Override
	public boolean isEntityCacheEnabled() {
		return ENTITY_CACHE_ENABLED;
	}

	@Override
	public boolean isFinderCacheEnabled() {
		return FINDER_CACHE_ENABLED;
	}

	@Override
	public void resetOriginalValues() {
		_originalUuid = _uuid;

		_originalHeadId = _headId;

		_setOriginalHeadId = false;

		_originalHead = _head;

		_setOriginalHead = false;

		_originalGroupId = _groupId;

		_setOriginalGroupId = false;

		_originalCompanyId = _companyId;

		_setOriginalCompanyId = false;

		_setModifiedDate = false;
		_originalParentPlid = _parentPlid;

		_setOriginalParentPlid = false;

		_originalPrivateLayout = _privateLayout;

		_setOriginalPrivateLayout = false;

		_originalLayoutId = _layoutId;

		_setOriginalLayoutId = false;

		_originalParentLayoutId = _parentLayoutId;

		_setOriginalParentLayoutId = false;

		_originalClassNameId = _classNameId;

		_setOriginalClassNameId = false;

		_originalClassPK = _classPK;

		_setOriginalClassPK = false;

		_originalType = _type;

		_originalHidden = _hidden;

		_setOriginalHidden = false;

		_originalSystem = _system;

		_setOriginalSystem = false;

		_originalFriendlyURL = _friendlyURL;

		_originalIconImageId = _iconImageId;

		_setOriginalIconImageId = false;

		_originalPriority = _priority;

		_setOriginalPriority = false;

		_originalLayoutPrototypeUuid = _layoutPrototypeUuid;

		_originalSourcePrototypeLayoutUuid = _sourcePrototypeLayoutUuid;

		_columnBitmask = 0;
	}

	@Override
	public CacheModel<Layout> toCacheModel() {
		LayoutCacheModel layoutCacheModel = new LayoutCacheModel();

		layoutCacheModel.mvccVersion = getMvccVersion();

		layoutCacheModel.uuid = getUuid();

		String uuid = layoutCacheModel.uuid;

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

		layoutCacheModel.headId = getHeadId();

		layoutCacheModel.head = isHead();

		layoutCacheModel.plid = getPlid();

		layoutCacheModel.groupId = getGroupId();

		layoutCacheModel.companyId = getCompanyId();

		layoutCacheModel.userId = getUserId();

		layoutCacheModel.userName = getUserName();

		String userName = layoutCacheModel.userName;

		if ((userName != null) && (userName.length() == 0)) {
			layoutCacheModel.userName = null;
		}

		Date createDate = getCreateDate();

		if (createDate != null) {
			layoutCacheModel.createDate = createDate.getTime();
		}
		else {
			layoutCacheModel.createDate = Long.MIN_VALUE;
		}

		Date modifiedDate = getModifiedDate();

		if (modifiedDate != null) {
			layoutCacheModel.modifiedDate = modifiedDate.getTime();
		}
		else {
			layoutCacheModel.modifiedDate = Long.MIN_VALUE;
		}

		layoutCacheModel.parentPlid = getParentPlid();

		layoutCacheModel.privateLayout = isPrivateLayout();

		layoutCacheModel.layoutId = getLayoutId();

		layoutCacheModel.parentLayoutId = getParentLayoutId();

		layoutCacheModel.classNameId = getClassNameId();

		layoutCacheModel.classPK = getClassPK();

		layoutCacheModel.name = getName();

		String name = layoutCacheModel.name;

		if ((name != null) && (name.length() == 0)) {
			layoutCacheModel.name = null;
		}

		layoutCacheModel.title = getTitle();

		String title = layoutCacheModel.title;

		if ((title != null) && (title.length() == 0)) {
			layoutCacheModel.title = null;
		}

		layoutCacheModel.description = getDescription();

		String description = layoutCacheModel.description;

		if ((description != null) && (description.length() == 0)) {
			layoutCacheModel.description = null;
		}

		layoutCacheModel.keywords = getKeywords();

		String keywords = layoutCacheModel.keywords;

		if ((keywords != null) && (keywords.length() == 0)) {
			layoutCacheModel.keywords = null;
		}

		layoutCacheModel.robots = getRobots();

		String robots = layoutCacheModel.robots;

		if ((robots != null) && (robots.length() == 0)) {
			layoutCacheModel.robots = null;
		}

		layoutCacheModel.type = getType();

		String type = layoutCacheModel.type;

		if ((type != null) && (type.length() == 0)) {
			layoutCacheModel.type = null;
		}

		layoutCacheModel.typeSettings = getTypeSettings();

		String typeSettings = layoutCacheModel.typeSettings;

		if ((typeSettings != null) && (typeSettings.length() == 0)) {
			layoutCacheModel.typeSettings = null;
		}

		layoutCacheModel.hidden = isHidden();

		layoutCacheModel.system = isSystem();

		layoutCacheModel.friendlyURL = getFriendlyURL();

		String friendlyURL = layoutCacheModel.friendlyURL;

		if ((friendlyURL != null) && (friendlyURL.length() == 0)) {
			layoutCacheModel.friendlyURL = null;
		}

		layoutCacheModel.iconImageId = getIconImageId();

		layoutCacheModel.themeId = getThemeId();

		String themeId = layoutCacheModel.themeId;

		if ((themeId != null) && (themeId.length() == 0)) {
			layoutCacheModel.themeId = null;
		}

		layoutCacheModel.colorSchemeId = getColorSchemeId();

		String colorSchemeId = layoutCacheModel.colorSchemeId;

		if ((colorSchemeId != null) && (colorSchemeId.length() == 0)) {
			layoutCacheModel.colorSchemeId = null;
		}

		layoutCacheModel.css = getCss();

		String css = layoutCacheModel.css;

		if ((css != null) && (css.length() == 0)) {
			layoutCacheModel.css = null;
		}

		layoutCacheModel.priority = getPriority();

		layoutCacheModel.layoutPrototypeUuid = getLayoutPrototypeUuid();

		String layoutPrototypeUuid = layoutCacheModel.layoutPrototypeUuid;

		if ((layoutPrototypeUuid != null) &&
			(layoutPrototypeUuid.length() == 0)) {

			layoutCacheModel.layoutPrototypeUuid = null;
		}

		layoutCacheModel.layoutPrototypeLinkEnabled =
			isLayoutPrototypeLinkEnabled();

		layoutCacheModel.sourcePrototypeLayoutUuid =
			getSourcePrototypeLayoutUuid();

		String sourcePrototypeLayoutUuid =
			layoutCacheModel.sourcePrototypeLayoutUuid;

		if ((sourcePrototypeLayoutUuid != null) &&
			(sourcePrototypeLayoutUuid.length() == 0)) {

			layoutCacheModel.sourcePrototypeLayoutUuid = null;
		}

		Date publishDate = getPublishDate();

		if (publishDate != null) {
			layoutCacheModel.publishDate = publishDate.getTime();
		}
		else {
			layoutCacheModel.publishDate = Long.MIN_VALUE;
		}

		Date lastPublishDate = getLastPublishDate();

		if (lastPublishDate != null) {
			layoutCacheModel.lastPublishDate = lastPublishDate.getTime();
		}
		else {
			layoutCacheModel.lastPublishDate = Long.MIN_VALUE;
		}

		return layoutCacheModel;
	}

	@Override
	public String toString() {
		Map<String, Function<Layout, Object>> attributeGetterFunctions =
			getAttributeGetterFunctions();

		StringBundler sb = new StringBundler(
			(5 * attributeGetterFunctions.size()) + 2);

		sb.append("{");

		for (Map.Entry<String, Function<Layout, Object>> entry :
				attributeGetterFunctions.entrySet()) {

			String attributeName = entry.getKey();
			Function<Layout, Object> attributeGetterFunction = entry.getValue();

			sb.append("\"");
			sb.append(attributeName);
			sb.append("\": ");

			Object value = attributeGetterFunction.apply((Layout)this);

			if (value == null) {
				sb.append("null");
			}
			else if (value instanceof Blob || value instanceof Date ||
					 value instanceof Map || value instanceof String) {

				sb.append(
					"\"" + StringUtil.replace(value.toString(), "\"", "'") +
						"\"");
			}
			else {
				sb.append(value);
			}

			sb.append(", ");
		}

		if (sb.index() > 1) {
			sb.setIndex(sb.index() - 1);
		}

		sb.append("}");

		return sb.toString();
	}

	@Override
	public String toXmlString() {
		Map<String, Function<Layout, Object>> attributeGetterFunctions =
			getAttributeGetterFunctions();

		StringBundler sb = new StringBundler(
			(5 * attributeGetterFunctions.size()) + 4);

		sb.append("<model><model-name>");
		sb.append(getModelClassName());
		sb.append("</model-name>");

		for (Map.Entry<String, Function<Layout, Object>> entry :
				attributeGetterFunctions.entrySet()) {

			String attributeName = entry.getKey();
			Function<Layout, Object> attributeGetterFunction = entry.getValue();

			sb.append("<column><column-name>");
			sb.append(attributeName);
			sb.append("</column-name><column-value><![CDATA[");
			sb.append(attributeGetterFunction.apply((Layout)this));
			sb.append("]]></column-value></column>");
		}

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

		return sb.toString();
	}

	private static class EscapedModelProxyProviderFunctionHolder {

		private static final Function<InvocationHandler, Layout>
			_escapedModelProxyProviderFunction = _getProxyProviderFunction();

	}

	private long _mvccVersion;
	private String _uuid;
	private String _originalUuid;
	private long _headId;
	private long _originalHeadId;
	private boolean _setOriginalHeadId;
	private boolean _head;
	private boolean _originalHead;
	private boolean _setOriginalHead;
	private long _plid;
	private long _groupId;
	private long _originalGroupId;
	private boolean _setOriginalGroupId;
	private long _companyId;
	private long _originalCompanyId;
	private boolean _setOriginalCompanyId;
	private long _userId;
	private String _userName;
	private Date _createDate;
	private Date _modifiedDate;
	private boolean _setModifiedDate;
	private long _parentPlid;
	private long _originalParentPlid;
	private boolean _setOriginalParentPlid;
	private boolean _privateLayout;
	private boolean _originalPrivateLayout;
	private boolean _setOriginalPrivateLayout;
	private long _layoutId;
	private long _originalLayoutId;
	private boolean _setOriginalLayoutId;
	private long _parentLayoutId;
	private long _originalParentLayoutId;
	private boolean _setOriginalParentLayoutId;
	private long _classNameId;
	private long _originalClassNameId;
	private boolean _setOriginalClassNameId;
	private long _classPK;
	private long _originalClassPK;
	private boolean _setOriginalClassPK;
	private String _name;
	private String _nameCurrentLanguageId;
	private String _title;
	private String _titleCurrentLanguageId;
	private String _description;
	private String _descriptionCurrentLanguageId;
	private String _keywords;
	private String _keywordsCurrentLanguageId;
	private String _robots;
	private String _robotsCurrentLanguageId;
	private String _type;
	private String _originalType;
	private String _typeSettings;
	private boolean _hidden;
	private boolean _originalHidden;
	private boolean _setOriginalHidden;
	private boolean _system;
	private boolean _originalSystem;
	private boolean _setOriginalSystem;
	private String _friendlyURL;
	private String _originalFriendlyURL;
	private long _iconImageId;
	private long _originalIconImageId;
	private boolean _setOriginalIconImageId;
	private String _themeId;
	private String _colorSchemeId;
	private String _css;
	private int _priority;
	private int _originalPriority;
	private boolean _setOriginalPriority;
	private String _layoutPrototypeUuid;
	private String _originalLayoutPrototypeUuid;
	private boolean _layoutPrototypeLinkEnabled;
	private String _sourcePrototypeLayoutUuid;
	private String _originalSourcePrototypeLayoutUuid;
	private Date _publishDate;
	private Date _lastPublishDate;
	private long _columnBitmask;
	private Layout _escapedModel;

}