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.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            @Override
061            public ExpandoColumn toEntityModel() {
062                    ExpandoColumnImpl expandoColumnImpl = new ExpandoColumnImpl();
063    
064                    expandoColumnImpl.setColumnId(columnId);
065                    expandoColumnImpl.setCompanyId(companyId);
066                    expandoColumnImpl.setTableId(tableId);
067    
068                    if (name == null) {
069                            expandoColumnImpl.setName(StringPool.BLANK);
070                    }
071                    else {
072                            expandoColumnImpl.setName(name);
073                    }
074    
075                    expandoColumnImpl.setType(type);
076    
077                    if (defaultData == null) {
078                            expandoColumnImpl.setDefaultData(StringPool.BLANK);
079                    }
080                    else {
081                            expandoColumnImpl.setDefaultData(defaultData);
082                    }
083    
084                    if (typeSettings == null) {
085                            expandoColumnImpl.setTypeSettings(StringPool.BLANK);
086                    }
087                    else {
088                            expandoColumnImpl.setTypeSettings(typeSettings);
089                    }
090    
091                    expandoColumnImpl.resetOriginalValues();
092    
093                    return expandoColumnImpl;
094            }
095    
096            @Override
097            public void readExternal(ObjectInput objectInput) throws IOException {
098                    columnId = objectInput.readLong();
099                    companyId = objectInput.readLong();
100                    tableId = objectInput.readLong();
101                    name = objectInput.readUTF();
102                    type = objectInput.readInt();
103                    defaultData = objectInput.readUTF();
104                    typeSettings = objectInput.readUTF();
105            }
106    
107            @Override
108            public void writeExternal(ObjectOutput objectOutput)
109                    throws IOException {
110                    objectOutput.writeLong(columnId);
111                    objectOutput.writeLong(companyId);
112                    objectOutput.writeLong(tableId);
113    
114                    if (name == null) {
115                            objectOutput.writeUTF(StringPool.BLANK);
116                    }
117                    else {
118                            objectOutput.writeUTF(name);
119                    }
120    
121                    objectOutput.writeInt(type);
122    
123                    if (defaultData == null) {
124                            objectOutput.writeUTF(StringPool.BLANK);
125                    }
126                    else {
127                            objectOutput.writeUTF(defaultData);
128                    }
129    
130                    if (typeSettings == null) {
131                            objectOutput.writeUTF(StringPool.BLANK);
132                    }
133                    else {
134                            objectOutput.writeUTF(typeSettings);
135                    }
136            }
137    
138            public long columnId;
139            public long companyId;
140            public long tableId;
141            public String name;
142            public int type;
143            public String defaultData;
144            public String typeSettings;
145    }