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