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.announcements.model.impl;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.model.CacheModel;
019    
020    import com.liferay.portlet.announcements.model.AnnouncementsFlag;
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 AnnouncementsFlag in entity cache.
031     *
032     * @author Brian Wing Shun Chan
033     * @see AnnouncementsFlag
034     * @generated
035     */
036    public class AnnouncementsFlagCacheModel implements CacheModel<AnnouncementsFlag>,
037            Externalizable {
038            @Override
039            public String toString() {
040                    StringBundler sb = new StringBundler(11);
041    
042                    sb.append("{flagId=");
043                    sb.append(flagId);
044                    sb.append(", userId=");
045                    sb.append(userId);
046                    sb.append(", createDate=");
047                    sb.append(createDate);
048                    sb.append(", entryId=");
049                    sb.append(entryId);
050                    sb.append(", value=");
051                    sb.append(value);
052                    sb.append("}");
053    
054                    return sb.toString();
055            }
056    
057            @Override
058            public AnnouncementsFlag toEntityModel() {
059                    AnnouncementsFlagImpl announcementsFlagImpl = new AnnouncementsFlagImpl();
060    
061                    announcementsFlagImpl.setFlagId(flagId);
062                    announcementsFlagImpl.setUserId(userId);
063    
064                    if (createDate == Long.MIN_VALUE) {
065                            announcementsFlagImpl.setCreateDate(null);
066                    }
067                    else {
068                            announcementsFlagImpl.setCreateDate(new Date(createDate));
069                    }
070    
071                    announcementsFlagImpl.setEntryId(entryId);
072                    announcementsFlagImpl.setValue(value);
073    
074                    announcementsFlagImpl.resetOriginalValues();
075    
076                    return announcementsFlagImpl;
077            }
078    
079            @Override
080            public void readExternal(ObjectInput objectInput) throws IOException {
081                    flagId = objectInput.readLong();
082                    userId = objectInput.readLong();
083                    createDate = objectInput.readLong();
084                    entryId = objectInput.readLong();
085                    value = objectInput.readInt();
086            }
087    
088            @Override
089            public void writeExternal(ObjectOutput objectOutput)
090                    throws IOException {
091                    objectOutput.writeLong(flagId);
092                    objectOutput.writeLong(userId);
093                    objectOutput.writeLong(createDate);
094                    objectOutput.writeLong(entryId);
095                    objectOutput.writeInt(value);
096            }
097    
098            public long flagId;
099            public long userId;
100            public long createDate;
101            public long entryId;
102            public int value;
103    }