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.expando.kernel.model.ExpandoTable;
020    
021    import com.liferay.portal.kernel.model.CacheModel;
022    import com.liferay.portal.kernel.util.HashUtil;
023    import com.liferay.portal.kernel.util.StringBundler;
024    import com.liferay.portal.kernel.util.StringPool;
025    
026    import java.io.Externalizable;
027    import java.io.IOException;
028    import java.io.ObjectInput;
029    import java.io.ObjectOutput;
030    
031    /**
032     * The cache model class for representing ExpandoTable in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see ExpandoTable
036     * @generated
037     */
038    @ProviderType
039    public class ExpandoTableCacheModel implements CacheModel<ExpandoTable>,
040            Externalizable {
041            @Override
042            public boolean equals(Object obj) {
043                    if (this == obj) {
044                            return true;
045                    }
046    
047                    if (!(obj instanceof ExpandoTableCacheModel)) {
048                            return false;
049                    }
050    
051                    ExpandoTableCacheModel expandoTableCacheModel = (ExpandoTableCacheModel)obj;
052    
053                    if (tableId == expandoTableCacheModel.tableId) {
054                            return true;
055                    }
056    
057                    return false;
058            }
059    
060            @Override
061            public int hashCode() {
062                    return HashUtil.hash(0, tableId);
063            }
064    
065            @Override
066            public String toString() {
067                    StringBundler sb = new StringBundler(9);
068    
069                    sb.append("{tableId=");
070                    sb.append(tableId);
071                    sb.append(", companyId=");
072                    sb.append(companyId);
073                    sb.append(", classNameId=");
074                    sb.append(classNameId);
075                    sb.append(", name=");
076                    sb.append(name);
077                    sb.append("}");
078    
079                    return sb.toString();
080            }
081    
082            @Override
083            public ExpandoTable toEntityModel() {
084                    ExpandoTableImpl expandoTableImpl = new ExpandoTableImpl();
085    
086                    expandoTableImpl.setTableId(tableId);
087                    expandoTableImpl.setCompanyId(companyId);
088                    expandoTableImpl.setClassNameId(classNameId);
089    
090                    if (name == null) {
091                            expandoTableImpl.setName(StringPool.BLANK);
092                    }
093                    else {
094                            expandoTableImpl.setName(name);
095                    }
096    
097                    expandoTableImpl.resetOriginalValues();
098    
099                    return expandoTableImpl;
100            }
101    
102            @Override
103            public void readExternal(ObjectInput objectInput) throws IOException {
104                    tableId = objectInput.readLong();
105    
106                    companyId = objectInput.readLong();
107    
108                    classNameId = objectInput.readLong();
109                    name = objectInput.readUTF();
110            }
111    
112            @Override
113            public void writeExternal(ObjectOutput objectOutput)
114                    throws IOException {
115                    objectOutput.writeLong(tableId);
116    
117                    objectOutput.writeLong(companyId);
118    
119                    objectOutput.writeLong(classNameId);
120    
121                    if (name == null) {
122                            objectOutput.writeUTF(StringPool.BLANK);
123                    }
124                    else {
125                            objectOutput.writeUTF(name);
126                    }
127            }
128    
129            public long tableId;
130            public long companyId;
131            public long classNameId;
132            public String name;
133    }