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.portal.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    import com.liferay.portal.model.Lock;
021    
022    import java.io.Externalizable;
023    import java.io.IOException;
024    import java.io.ObjectInput;
025    import java.io.ObjectOutput;
026    
027    import java.util.Date;
028    
029    /**
030     * The cache model class for representing Lock in entity cache.
031     *
032     * @author Brian Wing Shun Chan
033     * @see Lock
034     * @generated
035     */
036    public class LockCacheModel implements CacheModel<Lock>, Externalizable {
037            @Override
038            public String toString() {
039                    StringBundler sb = new StringBundler(23);
040    
041                    sb.append("{uuid=");
042                    sb.append(uuid);
043                    sb.append(", lockId=");
044                    sb.append(lockId);
045                    sb.append(", companyId=");
046                    sb.append(companyId);
047                    sb.append(", userId=");
048                    sb.append(userId);
049                    sb.append(", userName=");
050                    sb.append(userName);
051                    sb.append(", createDate=");
052                    sb.append(createDate);
053                    sb.append(", className=");
054                    sb.append(className);
055                    sb.append(", key=");
056                    sb.append(key);
057                    sb.append(", owner=");
058                    sb.append(owner);
059                    sb.append(", inheritable=");
060                    sb.append(inheritable);
061                    sb.append(", expirationDate=");
062                    sb.append(expirationDate);
063                    sb.append("}");
064    
065                    return sb.toString();
066            }
067    
068            public Lock toEntityModel() {
069                    LockImpl lockImpl = new LockImpl();
070    
071                    if (uuid == null) {
072                            lockImpl.setUuid(StringPool.BLANK);
073                    }
074                    else {
075                            lockImpl.setUuid(uuid);
076                    }
077    
078                    lockImpl.setLockId(lockId);
079                    lockImpl.setCompanyId(companyId);
080                    lockImpl.setUserId(userId);
081    
082                    if (userName == null) {
083                            lockImpl.setUserName(StringPool.BLANK);
084                    }
085                    else {
086                            lockImpl.setUserName(userName);
087                    }
088    
089                    if (createDate == Long.MIN_VALUE) {
090                            lockImpl.setCreateDate(null);
091                    }
092                    else {
093                            lockImpl.setCreateDate(new Date(createDate));
094                    }
095    
096                    if (className == null) {
097                            lockImpl.setClassName(StringPool.BLANK);
098                    }
099                    else {
100                            lockImpl.setClassName(className);
101                    }
102    
103                    if (key == null) {
104                            lockImpl.setKey(StringPool.BLANK);
105                    }
106                    else {
107                            lockImpl.setKey(key);
108                    }
109    
110                    if (owner == null) {
111                            lockImpl.setOwner(StringPool.BLANK);
112                    }
113                    else {
114                            lockImpl.setOwner(owner);
115                    }
116    
117                    lockImpl.setInheritable(inheritable);
118    
119                    if (expirationDate == Long.MIN_VALUE) {
120                            lockImpl.setExpirationDate(null);
121                    }
122                    else {
123                            lockImpl.setExpirationDate(new Date(expirationDate));
124                    }
125    
126                    lockImpl.resetOriginalValues();
127    
128                    return lockImpl;
129            }
130    
131            public void readExternal(ObjectInput objectInput) throws IOException {
132                    uuid = objectInput.readUTF();
133                    lockId = objectInput.readLong();
134                    companyId = objectInput.readLong();
135                    userId = objectInput.readLong();
136                    userName = objectInput.readUTF();
137                    createDate = objectInput.readLong();
138                    className = objectInput.readUTF();
139                    key = objectInput.readUTF();
140                    owner = objectInput.readUTF();
141                    inheritable = objectInput.readBoolean();
142                    expirationDate = objectInput.readLong();
143            }
144    
145            public void writeExternal(ObjectOutput objectOutput)
146                    throws IOException {
147                    if (uuid == null) {
148                            objectOutput.writeUTF(StringPool.BLANK);
149                    }
150                    else {
151                            objectOutput.writeUTF(uuid);
152                    }
153    
154                    objectOutput.writeLong(lockId);
155                    objectOutput.writeLong(companyId);
156                    objectOutput.writeLong(userId);
157    
158                    if (userName == null) {
159                            objectOutput.writeUTF(StringPool.BLANK);
160                    }
161                    else {
162                            objectOutput.writeUTF(userName);
163                    }
164    
165                    objectOutput.writeLong(createDate);
166    
167                    if (className == null) {
168                            objectOutput.writeUTF(StringPool.BLANK);
169                    }
170                    else {
171                            objectOutput.writeUTF(className);
172                    }
173    
174                    if (key == null) {
175                            objectOutput.writeUTF(StringPool.BLANK);
176                    }
177                    else {
178                            objectOutput.writeUTF(key);
179                    }
180    
181                    if (owner == null) {
182                            objectOutput.writeUTF(StringPool.BLANK);
183                    }
184                    else {
185                            objectOutput.writeUTF(owner);
186                    }
187    
188                    objectOutput.writeBoolean(inheritable);
189                    objectOutput.writeLong(expirationDate);
190            }
191    
192            public String uuid;
193            public long lockId;
194            public long companyId;
195            public long userId;
196            public String userName;
197            public long createDate;
198            public String className;
199            public String key;
200            public String owner;
201            public boolean inheritable;
202            public long expirationDate;
203    }