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.dynamicdatamapping.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.dynamicdatamapping.model.DDMStructureVersion;
024    
025    import java.io.Externalizable;
026    import java.io.IOException;
027    import java.io.ObjectInput;
028    import java.io.ObjectOutput;
029    
030    import java.util.Date;
031    
032    /**
033     * The cache model class for representing DDMStructureVersion in entity cache.
034     *
035     * @author Brian Wing Shun Chan
036     * @see DDMStructureVersion
037     * @generated
038     */
039    @ProviderType
040    public class DDMStructureVersionCacheModel implements CacheModel<DDMStructureVersion>,
041            Externalizable {
042            @Override
043            public String toString() {
044                    StringBundler sb = new StringBundler(27);
045    
046                    sb.append("{structureVersionId=");
047                    sb.append(structureVersionId);
048                    sb.append(", groupId=");
049                    sb.append(groupId);
050                    sb.append(", companyId=");
051                    sb.append(companyId);
052                    sb.append(", userId=");
053                    sb.append(userId);
054                    sb.append(", userName=");
055                    sb.append(userName);
056                    sb.append(", createDate=");
057                    sb.append(createDate);
058                    sb.append(", structureId=");
059                    sb.append(structureId);
060                    sb.append(", version=");
061                    sb.append(version);
062                    sb.append(", name=");
063                    sb.append(name);
064                    sb.append(", description=");
065                    sb.append(description);
066                    sb.append(", definition=");
067                    sb.append(definition);
068                    sb.append(", storageType=");
069                    sb.append(storageType);
070                    sb.append(", type=");
071                    sb.append(type);
072                    sb.append("}");
073    
074                    return sb.toString();
075            }
076    
077            @Override
078            public DDMStructureVersion toEntityModel() {
079                    DDMStructureVersionImpl ddmStructureVersionImpl = new DDMStructureVersionImpl();
080    
081                    ddmStructureVersionImpl.setStructureVersionId(structureVersionId);
082                    ddmStructureVersionImpl.setGroupId(groupId);
083                    ddmStructureVersionImpl.setCompanyId(companyId);
084                    ddmStructureVersionImpl.setUserId(userId);
085    
086                    if (userName == null) {
087                            ddmStructureVersionImpl.setUserName(StringPool.BLANK);
088                    }
089                    else {
090                            ddmStructureVersionImpl.setUserName(userName);
091                    }
092    
093                    if (createDate == Long.MIN_VALUE) {
094                            ddmStructureVersionImpl.setCreateDate(null);
095                    }
096                    else {
097                            ddmStructureVersionImpl.setCreateDate(new Date(createDate));
098                    }
099    
100                    ddmStructureVersionImpl.setStructureId(structureId);
101    
102                    if (version == null) {
103                            ddmStructureVersionImpl.setVersion(StringPool.BLANK);
104                    }
105                    else {
106                            ddmStructureVersionImpl.setVersion(version);
107                    }
108    
109                    if (name == null) {
110                            ddmStructureVersionImpl.setName(StringPool.BLANK);
111                    }
112                    else {
113                            ddmStructureVersionImpl.setName(name);
114                    }
115    
116                    if (description == null) {
117                            ddmStructureVersionImpl.setDescription(StringPool.BLANK);
118                    }
119                    else {
120                            ddmStructureVersionImpl.setDescription(description);
121                    }
122    
123                    if (definition == null) {
124                            ddmStructureVersionImpl.setDefinition(StringPool.BLANK);
125                    }
126                    else {
127                            ddmStructureVersionImpl.setDefinition(definition);
128                    }
129    
130                    if (storageType == null) {
131                            ddmStructureVersionImpl.setStorageType(StringPool.BLANK);
132                    }
133                    else {
134                            ddmStructureVersionImpl.setStorageType(storageType);
135                    }
136    
137                    ddmStructureVersionImpl.setType(type);
138    
139                    ddmStructureVersionImpl.resetOriginalValues();
140    
141                    return ddmStructureVersionImpl;
142            }
143    
144            @Override
145            public void readExternal(ObjectInput objectInput) throws IOException {
146                    structureVersionId = objectInput.readLong();
147                    groupId = objectInput.readLong();
148                    companyId = objectInput.readLong();
149                    userId = objectInput.readLong();
150                    userName = objectInput.readUTF();
151                    createDate = objectInput.readLong();
152                    structureId = objectInput.readLong();
153                    version = objectInput.readUTF();
154                    name = objectInput.readUTF();
155                    description = objectInput.readUTF();
156                    definition = objectInput.readUTF();
157                    storageType = objectInput.readUTF();
158                    type = objectInput.readInt();
159            }
160    
161            @Override
162            public void writeExternal(ObjectOutput objectOutput)
163                    throws IOException {
164                    objectOutput.writeLong(structureVersionId);
165                    objectOutput.writeLong(groupId);
166                    objectOutput.writeLong(companyId);
167                    objectOutput.writeLong(userId);
168    
169                    if (userName == null) {
170                            objectOutput.writeUTF(StringPool.BLANK);
171                    }
172                    else {
173                            objectOutput.writeUTF(userName);
174                    }
175    
176                    objectOutput.writeLong(createDate);
177                    objectOutput.writeLong(structureId);
178    
179                    if (version == null) {
180                            objectOutput.writeUTF(StringPool.BLANK);
181                    }
182                    else {
183                            objectOutput.writeUTF(version);
184                    }
185    
186                    if (name == null) {
187                            objectOutput.writeUTF(StringPool.BLANK);
188                    }
189                    else {
190                            objectOutput.writeUTF(name);
191                    }
192    
193                    if (description == null) {
194                            objectOutput.writeUTF(StringPool.BLANK);
195                    }
196                    else {
197                            objectOutput.writeUTF(description);
198                    }
199    
200                    if (definition == null) {
201                            objectOutput.writeUTF(StringPool.BLANK);
202                    }
203                    else {
204                            objectOutput.writeUTF(definition);
205                    }
206    
207                    if (storageType == null) {
208                            objectOutput.writeUTF(StringPool.BLANK);
209                    }
210                    else {
211                            objectOutput.writeUTF(storageType);
212                    }
213    
214                    objectOutput.writeInt(type);
215            }
216    
217            public long structureVersionId;
218            public long groupId;
219            public long companyId;
220            public long userId;
221            public String userName;
222            public long createDate;
223            public long structureId;
224            public String version;
225            public String name;
226            public String description;
227            public String definition;
228            public String storageType;
229            public int type;
230    }