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.ExpandoColumn;
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 ExpandoColumn in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see ExpandoColumn
035     * @generated
036     */
037    @ProviderType
038    public class ExpandoColumnCacheModel implements CacheModel<ExpandoColumn>,
039            Externalizable {
040            @Override
041            public String toString() {
042                    StringBundler sb = new StringBundler(15);
043    
044                    sb.append("{columnId=");
045                    sb.append(columnId);
046                    sb.append(", companyId=");
047                    sb.append(companyId);
048                    sb.append(", tableId=");
049                    sb.append(tableId);
050                    sb.append(", name=");
051                    sb.append(name);
052                    sb.append(", type=");
053                    sb.append(type);
054                    sb.append(", defaultData=");
055                    sb.append(defaultData);
056                    sb.append(", typeSettings=");
057                    sb.append(typeSettings);
058                    sb.append("}");
059    
060                    return sb.toString();
061            }
062    
063            @Override
064            public ExpandoColumn toEntityModel() {
065                    ExpandoColumnImpl expandoColumnImpl = new ExpandoColumnImpl();
066    
067                    expandoColumnImpl.setColumnId(columnId);
068                    expandoColumnImpl.setCompanyId(companyId);
069                    expandoColumnImpl.setTableId(tableId);
070    
071                    if (name == null) {
072                            expandoColumnImpl.setName(StringPool.BLANK);
073                    }
074                    else {
075                            expandoColumnImpl.setName(name);
076                    }
077    
078                    expandoColumnImpl.setType(type);
079    
080                    if (defaultData == null) {
081                            expandoColumnImpl.setDefaultData(StringPool.BLANK);
082                    }
083                    else {
084                            expandoColumnImpl.setDefaultData(defaultData);
085                    }
086    
087                    if (typeSettings == null) {
088                            expandoColumnImpl.setTypeSettings(StringPool.BLANK);
089                    }
090                    else {
091                            expandoColumnImpl.setTypeSettings(typeSettings);
092                    }
093    
094                    expandoColumnImpl.resetOriginalValues();
095    
096                    return expandoColumnImpl;
097            }
098    
099            @Override
100            public void readExternal(ObjectInput objectInput) throws IOException {
101                    columnId = objectInput.readLong();
102                    companyId = objectInput.readLong();
103                    tableId = objectInput.readLong();
104                    name = objectInput.readUTF();
105                    type = objectInput.readInt();
106                    defaultData = objectInput.readUTF();
107                    typeSettings = objectInput.readUTF();
108            }
109    
110            @Override
111            public void writeExternal(ObjectOutput objectOutput)
112                    throws IOException {
113                    objectOutput.writeLong(columnId);
114                    objectOutput.writeLong(companyId);
115                    objectOutput.writeLong(tableId);
116    
117                    if (name == null) {
118                            objectOutput.writeUTF(StringPool.BLANK);
119                    }
120                    else {
121                            objectOutput.writeUTF(name);
122                    }
123    
124                    objectOutput.writeInt(type);
125    
126                    if (defaultData == null) {
127                            objectOutput.writeUTF(StringPool.BLANK);
128                    }
129                    else {
130                            objectOutput.writeUTF(defaultData);
131                    }
132    
133                    if (typeSettings == null) {
134                            objectOutput.writeUTF(StringPool.BLANK);
135                    }
136                    else {
137                            objectOutput.writeUTF(typeSettings);
138                    }
139            }
140    
141            public long columnId;
142            public long companyId;
143            public long tableId;
144            public String name;
145            public int type;
146            public String defaultData;
147            public String typeSettings;
148    }