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.portal.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.util.HashUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.CacheModel;
023    import com.liferay.portal.model.MVCCModel;
024    import com.liferay.portal.model.UserIdMapper;
025    
026    import java.io.Externalizable;
027    import java.io.IOException;
028    import java.io.ObjectInput;
029    import java.io.ObjectOutput;
030    
031    /**
032     * The cache model class for representing UserIdMapper in entity cache.
033     *
034     * @author Brian Wing Shun Chan
035     * @see UserIdMapper
036     * @generated
037     */
038    @ProviderType
039    public class UserIdMapperCacheModel implements CacheModel<UserIdMapper>,
040            Externalizable, MVCCModel {
041            @Override
042            public boolean equals(Object obj) {
043                    if (this == obj) {
044                            return true;
045                    }
046    
047                    if (!(obj instanceof UserIdMapperCacheModel)) {
048                            return false;
049                    }
050    
051                    UserIdMapperCacheModel userIdMapperCacheModel = (UserIdMapperCacheModel)obj;
052    
053                    if ((userIdMapperId == userIdMapperCacheModel.userIdMapperId) &&
054                                    (mvccVersion == userIdMapperCacheModel.mvccVersion)) {
055                            return true;
056                    }
057    
058                    return false;
059            }
060    
061            @Override
062            public int hashCode() {
063                    int hashCode = HashUtil.hash(0, userIdMapperId);
064    
065                    return HashUtil.hash(hashCode, mvccVersion);
066            }
067    
068            @Override
069            public long getMvccVersion() {
070                    return mvccVersion;
071            }
072    
073            @Override
074            public void setMvccVersion(long mvccVersion) {
075                    this.mvccVersion = mvccVersion;
076            }
077    
078            @Override
079            public String toString() {
080                    StringBundler sb = new StringBundler(13);
081    
082                    sb.append("{mvccVersion=");
083                    sb.append(mvccVersion);
084                    sb.append(", userIdMapperId=");
085                    sb.append(userIdMapperId);
086                    sb.append(", userId=");
087                    sb.append(userId);
088                    sb.append(", type=");
089                    sb.append(type);
090                    sb.append(", description=");
091                    sb.append(description);
092                    sb.append(", externalUserId=");
093                    sb.append(externalUserId);
094                    sb.append("}");
095    
096                    return sb.toString();
097            }
098    
099            @Override
100            public UserIdMapper toEntityModel() {
101                    UserIdMapperImpl userIdMapperImpl = new UserIdMapperImpl();
102    
103                    userIdMapperImpl.setMvccVersion(mvccVersion);
104                    userIdMapperImpl.setUserIdMapperId(userIdMapperId);
105                    userIdMapperImpl.setUserId(userId);
106    
107                    if (type == null) {
108                            userIdMapperImpl.setType(StringPool.BLANK);
109                    }
110                    else {
111                            userIdMapperImpl.setType(type);
112                    }
113    
114                    if (description == null) {
115                            userIdMapperImpl.setDescription(StringPool.BLANK);
116                    }
117                    else {
118                            userIdMapperImpl.setDescription(description);
119                    }
120    
121                    if (externalUserId == null) {
122                            userIdMapperImpl.setExternalUserId(StringPool.BLANK);
123                    }
124                    else {
125                            userIdMapperImpl.setExternalUserId(externalUserId);
126                    }
127    
128                    userIdMapperImpl.resetOriginalValues();
129    
130                    return userIdMapperImpl;
131            }
132    
133            @Override
134            public void readExternal(ObjectInput objectInput) throws IOException {
135                    mvccVersion = objectInput.readLong();
136                    userIdMapperId = objectInput.readLong();
137                    userId = objectInput.readLong();
138                    type = objectInput.readUTF();
139                    description = objectInput.readUTF();
140                    externalUserId = objectInput.readUTF();
141            }
142    
143            @Override
144            public void writeExternal(ObjectOutput objectOutput)
145                    throws IOException {
146                    objectOutput.writeLong(mvccVersion);
147                    objectOutput.writeLong(userIdMapperId);
148                    objectOutput.writeLong(userId);
149    
150                    if (type == null) {
151                            objectOutput.writeUTF(StringPool.BLANK);
152                    }
153                    else {
154                            objectOutput.writeUTF(type);
155                    }
156    
157                    if (description == null) {
158                            objectOutput.writeUTF(StringPool.BLANK);
159                    }
160                    else {
161                            objectOutput.writeUTF(description);
162                    }
163    
164                    if (externalUserId == null) {
165                            objectOutput.writeUTF(StringPool.BLANK);
166                    }
167                    else {
168                            objectOutput.writeUTF(externalUserId);
169                    }
170            }
171    
172            public long mvccVersion;
173            public long userIdMapperId;
174            public long userId;
175            public String type;
176            public String description;
177            public String externalUserId;
178    }