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 com.liferay.portal.service.ServiceContext#getExpandoBridgeAttributes( 129 * ) 130 */ 131 public void setExpandoBridgeAttributes(ServiceContext serviceContext); 132 133 public void setModelAttributes(Map<String, Object> attributes); 134 135 /** 136 * Sets whether this model instance does not yet exist in the database. 137 * 138 * @param n whether this model instance does not yet exist in the database 139 */ 140 public void setNew(boolean n); 141 142 /** 143 * Sets the primary key of this model instance. 144 * 145 * @param primaryKeyObj the primary key of this model instance 146 */ 147 @Override 148 public void setPrimaryKeyObj(Serializable primaryKeyObj); 149 150 /** 151 * Returns a cache model object for this entity used by entity cache. 152 * 153 * @return the cache model object 154 */ 155 public CacheModel<T> toCacheModel(); 156 157 /** 158 * Returns a copy of this entity as an escaped model instance by wrapping it 159 * with an {@link com.liferay.portal.kernel.bean.AutoEscapeBeanHandler}. 160 * 161 * @return the escaped model instance 162 * @see com.liferay.portal.kernel.bean.AutoEscapeBeanHandler 163 */ 164 public T toEscapedModel(); 165 166 public T toUnescapedModel(); 167 168 /** 169 * Returns the XML representation of this model instance. 170 * 171 * @return the XML representation of this model instance 172 */ 173 public String toXmlString(); 174 175 }