001    /**
002     * Copyright (c) 2000-2012 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.portlet.expando.model.impl;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.kernel.util.StringPool;
019    import com.liferay.portal.model.CacheModel;
020    
021    import com.liferay.portlet.expando.model.ExpandoTable;
022    
023    import java.io.Externalizable;
024    import java.io.IOException;
025    import java.io.ObjectInput;
026    import java.io.ObjectOutput;
027    
028    /**
029     * The cache model class for representing ExpandoTable in entity cache.
030     *
031     * @author Brian Wing Shun Chan
032     * @see ExpandoTable
033     * @generated
034     */
035    public class ExpandoTableCacheModel implements CacheModel<ExpandoTable>,
036            Externalizable {
037            @Override
038            public String toString() {
039                    StringBundler sb = new StringBundler(9);
040    
041                    sb.append("{tableId=");
042                    sb.append(tableId);
043                    sb.append(", companyId=");
044                    sb.append(companyId);
045                    sb.append(", classNameId=");
046                    sb.append(classNameId);
047                    sb.append(", name=");
048                    sb.append(name);
049                    sb.append("}");
050    
051                    return sb.toString();
052            }
053    
054            public ExpandoTable toEntityModel() {
055                    ExpandoTableImpl expandoTableImpl = new ExpandoTableImpl();
056    
057                    expandoTableImpl.setTableId(tableId);
058                    expandoTableImpl.setCompanyId(companyId);
059                    expandoTableImpl.setClassNameId(classNameId);
060    
061                    if (name == null) {
062                            expandoTableImpl.setName(StringPool.BLANK);
063                    }
064                    else {
065                            expandoTableImpl.setName(name);
066                    }
067    
068                    expandoTableImpl.resetOriginalValues();
069    
070                    return expandoTableImpl;
071            }
072    
073            public void readExternal(ObjectInput objectInput) throws IOException {
074                    tableId = objectInput.readLong();
075                    companyId = objectInput.readLong();
076                    classNameId = objectInput.readLong();
077                    name = objectInput.readUTF();
078            }
079    
080            public void writeExternal(ObjectOutput objectOutput)
081                    throws IOException {
082                    objectOutput.writeLong(tableId);
083                    objectOutput.writeLong(companyId);
084                    objectOutput.writeLong(classNameId);
085    
086                    if (name == null) {
087                            objectOutput.writeUTF(StringPool.BLANK);
088                    }
089                    else {
090                            objectOutput.writeUTF(name);
091                    }
092            }
093    
094            public long tableId;
095            public long companyId;
096            public long classNameId;
097            public String name;
098    }