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