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.portlet.messageboards.model.impl;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.model.CacheModel;
019    
020    import com.liferay.portlet.messageboards.model.MBThreadFlag;
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 MBThreadFlag in entity cache.
031     *
032     * @author Brian Wing Shun Chan
033     * @see MBThreadFlag
034     * @generated
035     */
036    public class MBThreadFlagCacheModel implements CacheModel<MBThreadFlag>,
037            Externalizable {
038            @Override
039            public String toString() {
040                    StringBundler sb = new StringBundler(9);
041    
042                    sb.append("{threadFlagId=");
043                    sb.append(threadFlagId);
044                    sb.append(", userId=");
045                    sb.append(userId);
046                    sb.append(", modifiedDate=");
047                    sb.append(modifiedDate);
048                    sb.append(", threadId=");
049                    sb.append(threadId);
050                    sb.append("}");
051    
052                    return sb.toString();
053            }
054    
055            public MBThreadFlag toEntityModel() {
056                    MBThreadFlagImpl mbThreadFlagImpl = new MBThreadFlagImpl();
057    
058                    mbThreadFlagImpl.setThreadFlagId(threadFlagId);
059                    mbThreadFlagImpl.setUserId(userId);
060    
061                    if (modifiedDate == Long.MIN_VALUE) {
062                            mbThreadFlagImpl.setModifiedDate(null);
063                    }
064                    else {
065                            mbThreadFlagImpl.setModifiedDate(new Date(modifiedDate));
066                    }
067    
068                    mbThreadFlagImpl.setThreadId(threadId);
069    
070                    mbThreadFlagImpl.resetOriginalValues();
071    
072                    return mbThreadFlagImpl;
073            }
074    
075            public void readExternal(ObjectInput objectInput) throws IOException {
076                    threadFlagId = objectInput.readLong();
077                    userId = objectInput.readLong();
078                    modifiedDate = objectInput.readLong();
079                    threadId = objectInput.readLong();
080            }
081    
082            public void writeExternal(ObjectOutput objectOutput)
083                    throws IOException {
084                    objectOutput.writeLong(threadFlagId);
085                    objectOutput.writeLong(userId);
086                    objectOutput.writeLong(modifiedDate);
087                    objectOutput.writeLong(threadId);
088            }
089    
090            public long threadFlagId;
091            public long userId;
092            public long modifiedDate;
093            public long threadId;
094    }