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.UserGroup;
021    
022    import java.io.Externalizable;
023    import java.io.IOException;
024    import java.io.ObjectInput;
025    import java.io.ObjectOutput;
026    
027    /**
028     * The cache model class for representing UserGroup in entity cache.
029     *
030     * @author Brian Wing Shun Chan
031     * @see UserGroup
032     * @generated
033     */
034    public class UserGroupCacheModel implements CacheModel<UserGroup>,
035            Externalizable {
036            @Override
037            public String toString() {
038                    StringBundler sb = new StringBundler(13);
039    
040                    sb.append("{userGroupId=");
041                    sb.append(userGroupId);
042                    sb.append(", companyId=");
043                    sb.append(companyId);
044                    sb.append(", parentUserGroupId=");
045                    sb.append(parentUserGroupId);
046                    sb.append(", name=");
047                    sb.append(name);
048                    sb.append(", description=");
049                    sb.append(description);
050                    sb.append(", addedByLDAPImport=");
051                    sb.append(addedByLDAPImport);
052                    sb.append("}");
053    
054                    return sb.toString();
055            }
056    
057            public UserGroup toEntityModel() {
058                    UserGroupImpl userGroupImpl = new UserGroupImpl();
059    
060                    userGroupImpl.setUserGroupId(userGroupId);
061                    userGroupImpl.setCompanyId(companyId);
062                    userGroupImpl.setParentUserGroupId(parentUserGroupId);
063    
064                    if (name == null) {
065                            userGroupImpl.setName(StringPool.BLANK);
066                    }
067                    else {
068                            userGroupImpl.setName(name);
069                    }
070    
071                    if (description == null) {
072                            userGroupImpl.setDescription(StringPool.BLANK);
073                    }
074                    else {
075                            userGroupImpl.setDescription(description);
076                    }
077    
078                    userGroupImpl.setAddedByLDAPImport(addedByLDAPImport);
079    
080                    userGroupImpl.resetOriginalValues();
081    
082                    return userGroupImpl;
083            }
084    
085            public void readExternal(ObjectInput objectInput) throws IOException {
086                    userGroupId = objectInput.readLong();
087                    companyId = objectInput.readLong();
088                    parentUserGroupId = objectInput.readLong();
089                    name = objectInput.readUTF();
090                    description = objectInput.readUTF();
091                    addedByLDAPImport = objectInput.readBoolean();
092            }
093    
094            public void writeExternal(ObjectOutput objectOutput)
095                    throws IOException {
096                    objectOutput.writeLong(userGroupId);
097                    objectOutput.writeLong(companyId);
098                    objectOutput.writeLong(parentUserGroupId);
099    
100                    if (name == null) {
101                            objectOutput.writeUTF(StringPool.BLANK);
102                    }
103                    else {
104                            objectOutput.writeUTF(name);
105                    }
106    
107                    if (description == null) {
108                            objectOutput.writeUTF(StringPool.BLANK);
109                    }
110                    else {
111                            objectOutput.writeUTF(description);
112                    }
113    
114                    objectOutput.writeBoolean(addedByLDAPImport);
115            }
116    
117            public long userGroupId;
118            public long companyId;
119            public long parentUserGroupId;
120            public String name;
121            public String description;
122            public boolean addedByLDAPImport;
123    }