001 /** 002 * Copyright (c) 2000-present Liferay, Inc. All rights reserved. 003 * 004 * This library is free software; you can redistribute it and/or modify it under 005 * the terms of the GNU Lesser General Public License as published by the Free 006 * Software Foundation; either version 2.1 of the License, or (at your option) 007 * any later version. 008 * 009 * This library is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 012 * details. 013 */ 014 015 package com.liferay.portal.model; 016 017 import aQute.bnd.annotation.ProviderType; 018 019 import com.liferay.portal.service.ServiceContext; 020 import com.liferay.portlet.expando.model.ExpandoBridge; 021 022 import java.io.Serializable; 023 024 import java.util.Map; 025 026 /** 027 * The base interface for all model classes. This interface should never need to 028 * be used directly. 029 * 030 * @author Brian Wing Shun Chan 031 * @see com.liferay.portal.model.impl.BaseModelImpl 032 */ 033 @ProviderType 034 public interface BaseModel<T> 035 extends ClassedModel, Cloneable, Comparable<T>, Serializable { 036 037 /** 038 * Creates a shallow clone of this model instance. 039 * 040 * @return the shallow clone of this model instance 041 */ 042 public Object clone(); 043 044 /** 045 * Returns the expando bridge for this model instance. 046 * 047 * @return the expando bridge for this model instance 048 */ 049 @Override 050 public ExpandoBridge getExpandoBridge(); 051 052 public Map<String, Object> getModelAttributes(); 053 054 /** 055 * Returns the primary key of this model instance. 056 * 057 * @return the primary key of this model instance 058 */ 059 @Override 060 public Serializable getPrimaryKeyObj(); 061 062 /** 063 * Returns <code>true</code> if this model instance was retrieved from the 064 * entity cache. 065 * 066 * @return <code>true</code> if this model instance was retrieved from the 067 * entity cache; <code>false</code> otherwise 068 * @see #setCachedModel(boolean) 069 */ 070 public boolean isCachedModel(); 071 072 /** 073 * Returns <code>true</code> if this model's entity cache is enabled. 074 * 075 * @return <code>true</code> if this model's entity cache is enabled; 076 * <code>false</code> otherwise 077 */ 078 public boolean isEntityCacheEnabled(); 079 080 /** 081 * Returns <code>true</code> if this model instance is escaped. 082 * 083 * @return <code>true</code> if this model instance is escaped; 084 * <code>false</code> otherwise 085 */ 086 public boolean isEscapedModel(); 087 088 /** 089 * Returns <code>true</code> if this model's finder cache is enabled. 090 * 091 * @return <code>true</code> if this model's finder cache is enabled; 092 * <code>false</code> otherwise 093 */ 094 public boolean isFinderCacheEnabled(); 095 096 /** 097 * Returns <code>true</code> if this model instance does not yet exist in 098 * the database. 099 * 100 * @return <code>true</code> if this model instance does not yet exist in 101 * the database; <code>false</code> otherwise 102 */ 103 public boolean isNew(); 104 105 /** 106 * Reset all original fields to current values. 107 */ 108 public void resetOriginalValues(); 109 110 /** 111 * Sets whether this model instance was retrieved from the entity cache. 112 * 113 * @param cachedModel whether this model instance was retrieved from the 114 * entity cache 115 * @see com.liferay.portal.kernel.dao.orm.EntityCache 116 */ 117 public void setCachedModel(boolean cachedModel); 118 119 public void setExpandoBridgeAttributes(BaseModel<?> baseModel); 120 121 public void setExpandoBridgeAttributes(ExpandoBridge expandoBridge); 122 123 /** 124 * Sets the expando bridge attributes for this model instance to the 125 * attributes stored in the service context. 126 * 127 * @param serviceContext the service context to be applied 128 * @see ServiceContext#getExpandoBridgeAttributes() 129 */ 130 public void setExpandoBridgeAttributes(ServiceContext serviceContext); 131 132 public void setModelAttributes(Map<String, Object> attributes); 133 134 /** 135 * Sets whether this model instance does not yet exist in the database. 136 * 137 * @param n whether this model instance does not yet exist in the database 138 */ 139 public void setNew(boolean n); 140 141 /** 142 * Sets the primary key of this model instance. 143 * 144 * @param primaryKeyObj the primary key of this model instance 145 */ 146 @Override 147 public void setPrimaryKeyObj(Serializable primaryKeyObj); 148 149 /** 150 * Returns a cache model object for this entity used by entity cache. 151 * 152 * @return the cache model object 153 */ 154 public CacheModel<T> toCacheModel(); 155 156 /** 157 * Returns a copy of this entity as an escaped model instance by wrapping it 158 * with an {@link com.liferay.portal.kernel.bean.AutoEscapeBeanHandler}. 159 * 160 * @return the escaped model instance 161 * @see com.liferay.portal.kernel.bean.AutoEscapeBeanHandler 162 */ 163 public T toEscapedModel(); 164 165 public T toUnescapedModel(); 166 167 /** 168 * Returns the XML representation of this model instance. 169 * 170 * @return the XML representation of this model instance 171 */ 172 public String toXmlString(); 173 174 }