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