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.asset.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    
024    import com.liferay.portlet.asset.model.AssetLink;
025    
026    import java.io.Externalizable;
027    import java.io.IOException;
028    import java.io.ObjectInput;
029    import java.io.ObjectOutput;
030    
031    import java.util.Date;
032    
033    /**
034     * The cache model class for representing AssetLink in entity cache.
035     *
036     * @author Brian Wing Shun Chan
037     * @see AssetLink
038     * @generated
039     */
040    @ProviderType
041    public class AssetLinkCacheModel implements CacheModel<AssetLink>,
042            Externalizable {
043            @Override
044            public boolean equals(Object obj) {
045                    if (this == obj) {
046                            return true;
047                    }
048    
049                    if (!(obj instanceof AssetLinkCacheModel)) {
050                            return false;
051                    }
052    
053                    AssetLinkCacheModel assetLinkCacheModel = (AssetLinkCacheModel)obj;
054    
055                    if (linkId == assetLinkCacheModel.linkId) {
056                            return true;
057                    }
058    
059                    return false;
060            }
061    
062            @Override
063            public int hashCode() {
064                    return HashUtil.hash(0, linkId);
065            }
066    
067            @Override
068            public String toString() {
069                    StringBundler sb = new StringBundler(19);
070    
071                    sb.append("{linkId=");
072                    sb.append(linkId);
073                    sb.append(", companyId=");
074                    sb.append(companyId);
075                    sb.append(", userId=");
076                    sb.append(userId);
077                    sb.append(", userName=");
078                    sb.append(userName);
079                    sb.append(", createDate=");
080                    sb.append(createDate);
081                    sb.append(", entryId1=");
082                    sb.append(entryId1);
083                    sb.append(", entryId2=");
084                    sb.append(entryId2);
085                    sb.append(", type=");
086                    sb.append(type);
087                    sb.append(", weight=");
088                    sb.append(weight);
089                    sb.append("}");
090    
091                    return sb.toString();
092            }
093    
094            @Override
095            public AssetLink toEntityModel() {
096                    AssetLinkImpl assetLinkImpl = new AssetLinkImpl();
097    
098                    assetLinkImpl.setLinkId(linkId);
099                    assetLinkImpl.setCompanyId(companyId);
100                    assetLinkImpl.setUserId(userId);
101    
102                    if (userName == null) {
103                            assetLinkImpl.setUserName(StringPool.BLANK);
104                    }
105                    else {
106                            assetLinkImpl.setUserName(userName);
107                    }
108    
109                    if (createDate == Long.MIN_VALUE) {
110                            assetLinkImpl.setCreateDate(null);
111                    }
112                    else {
113                            assetLinkImpl.setCreateDate(new Date(createDate));
114                    }
115    
116                    assetLinkImpl.setEntryId1(entryId1);
117                    assetLinkImpl.setEntryId2(entryId2);
118                    assetLinkImpl.setType(type);
119                    assetLinkImpl.setWeight(weight);
120    
121                    assetLinkImpl.resetOriginalValues();
122    
123                    return assetLinkImpl;
124            }
125    
126            @Override
127            public void readExternal(ObjectInput objectInput) throws IOException {
128                    linkId = objectInput.readLong();
129                    companyId = objectInput.readLong();
130                    userId = objectInput.readLong();
131                    userName = objectInput.readUTF();
132                    createDate = objectInput.readLong();
133                    entryId1 = objectInput.readLong();
134                    entryId2 = objectInput.readLong();
135                    type = objectInput.readInt();
136                    weight = objectInput.readInt();
137            }
138    
139            @Override
140            public void writeExternal(ObjectOutput objectOutput)
141                    throws IOException {
142                    objectOutput.writeLong(linkId);
143                    objectOutput.writeLong(companyId);
144                    objectOutput.writeLong(userId);
145    
146                    if (userName == null) {
147                            objectOutput.writeUTF(StringPool.BLANK);
148                    }
149                    else {
150                            objectOutput.writeUTF(userName);
151                    }
152    
153                    objectOutput.writeLong(createDate);
154                    objectOutput.writeLong(entryId1);
155                    objectOutput.writeLong(entryId2);
156                    objectOutput.writeInt(type);
157                    objectOutput.writeInt(weight);
158            }
159    
160            public long linkId;
161            public long companyId;
162            public long userId;
163            public String userName;
164            public long createDate;
165            public long entryId1;
166            public long entryId2;
167            public int type;
168            public int weight;
169    }