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