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.portlet.asset.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    
021    import com.liferay.portlet.asset.model.AssetLink;
022    
023    import java.io.Externalizable;
024    import java.io.IOException;
025    import java.io.ObjectInput;
026    import java.io.ObjectOutput;
027    
028    import java.util.Date;
029    
030    /**
031     * The cache model class for representing AssetLink in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see AssetLink
035     * @generated
036     */
037    public class AssetLinkCacheModel implements CacheModel<AssetLink>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(19);
042    
043                    sb.append("{linkId=");
044                    sb.append(linkId);
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(", entryId1=");
054                    sb.append(entryId1);
055                    sb.append(", entryId2=");
056                    sb.append(entryId2);
057                    sb.append(", type=");
058                    sb.append(type);
059                    sb.append(", weight=");
060                    sb.append(weight);
061                    sb.append("}");
062    
063                    return sb.toString();
064            }
065    
066            @Override
067            public AssetLink toEntityModel() {
068                    AssetLinkImpl assetLinkImpl = new AssetLinkImpl();
069    
070                    assetLinkImpl.setLinkId(linkId);
071                    assetLinkImpl.setCompanyId(companyId);
072                    assetLinkImpl.setUserId(userId);
073    
074                    if (userName == null) {
075                            assetLinkImpl.setUserName(StringPool.BLANK);
076                    }
077                    else {
078                            assetLinkImpl.setUserName(userName);
079                    }
080    
081                    if (createDate == Long.MIN_VALUE) {
082                            assetLinkImpl.setCreateDate(null);
083                    }
084                    else {
085                            assetLinkImpl.setCreateDate(new Date(createDate));
086                    }
087    
088                    assetLinkImpl.setEntryId1(entryId1);
089                    assetLinkImpl.setEntryId2(entryId2);
090                    assetLinkImpl.setType(type);
091                    assetLinkImpl.setWeight(weight);
092    
093                    assetLinkImpl.resetOriginalValues();
094    
095                    return assetLinkImpl;
096            }
097    
098            @Override
099            public void readExternal(ObjectInput objectInput) throws IOException {
100                    linkId = objectInput.readLong();
101                    companyId = objectInput.readLong();
102                    userId = objectInput.readLong();
103                    userName = objectInput.readUTF();
104                    createDate = objectInput.readLong();
105                    entryId1 = objectInput.readLong();
106                    entryId2 = objectInput.readLong();
107                    type = objectInput.readInt();
108                    weight = objectInput.readInt();
109            }
110    
111            @Override
112            public void writeExternal(ObjectOutput objectOutput)
113                    throws IOException {
114                    objectOutput.writeLong(linkId);
115                    objectOutput.writeLong(companyId);
116                    objectOutput.writeLong(userId);
117    
118                    if (userName == null) {
119                            objectOutput.writeUTF(StringPool.BLANK);
120                    }
121                    else {
122                            objectOutput.writeUTF(userName);
123                    }
124    
125                    objectOutput.writeLong(createDate);
126                    objectOutput.writeLong(entryId1);
127                    objectOutput.writeLong(entryId2);
128                    objectOutput.writeInt(type);
129                    objectOutput.writeInt(weight);
130            }
131    
132            public long linkId;
133            public long companyId;
134            public long userId;
135            public String userName;
136            public long createDate;
137            public long entryId1;
138            public long entryId2;
139            public int type;
140            public int weight;
141    }