001    /**
002     * Copyright (c) 2000-2013 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            @Override
055            public ExpandoTable toEntityModel() {
056                    ExpandoTableImpl expandoTableImpl = new ExpandoTableImpl();
057    
058                    expandoTableImpl.setTableId(tableId);
059                    expandoTableImpl.setCompanyId(companyId);
060                    expandoTableImpl.setClassNameId(classNameId);
061    
062                    if (name == null) {
063                            expandoTableImpl.setName(StringPool.BLANK);
064                    }
065                    else {
066                            expandoTableImpl.setName(name);
067                    }
068    
069                    expandoTableImpl.resetOriginalValues();
070    
071                    return expandoTableImpl;
072            }
073    
074            @Override
075            public void readExternal(ObjectInput objectInput) throws IOException {
076                    tableId = objectInput.readLong();
077                    companyId = objectInput.readLong();
078                    classNameId = objectInput.readLong();
079                    name = objectInput.readUTF();
080            }
081    
082            @Override
083            public void writeExternal(ObjectOutput objectOutput)
084                    throws IOException {
085                    objectOutput.writeLong(tableId);
086                    objectOutput.writeLong(companyId);
087                    objectOutput.writeLong(classNameId);
088    
089                    if (name == null) {
090                            objectOutput.writeUTF(StringPool.BLANK);
091                    }
092                    else {
093                            objectOutput.writeUTF(name);
094                    }
095            }
096    
097            public long tableId;
098            public long companyId;
099            public long classNameId;
100            public String name;
101    }