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.portal.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    import com.liferay.portal.model.ClassName;
021    
022    import java.io.Externalizable;
023    import java.io.IOException;
024    import java.io.ObjectInput;
025    import java.io.ObjectOutput;
026    
027    /**
028     * The cache model class for representing ClassName in entity cache.
029     *
030     * @author Brian Wing Shun Chan
031     * @see ClassName
032     * @generated
033     */
034    public class ClassNameCacheModel implements CacheModel<ClassName>,
035            Externalizable {
036            @Override
037            public String toString() {
038                    StringBundler sb = new StringBundler(5);
039    
040                    sb.append("{classNameId=");
041                    sb.append(classNameId);
042                    sb.append(", value=");
043                    sb.append(value);
044                    sb.append("}");
045    
046                    return sb.toString();
047            }
048    
049            @Override
050            public ClassName toEntityModel() {
051                    ClassNameImpl classNameImpl = new ClassNameImpl();
052    
053                    classNameImpl.setClassNameId(classNameId);
054    
055                    if (value == null) {
056                            classNameImpl.setValue(StringPool.BLANK);
057                    }
058                    else {
059                            classNameImpl.setValue(value);
060                    }
061    
062                    classNameImpl.resetOriginalValues();
063    
064                    return classNameImpl;
065            }
066    
067            @Override
068            public void readExternal(ObjectInput objectInput) throws IOException {
069                    classNameId = objectInput.readLong();
070                    value = objectInput.readUTF();
071            }
072    
073            @Override
074            public void writeExternal(ObjectOutput objectOutput)
075                    throws IOException {
076                    objectOutput.writeLong(classNameId);
077    
078                    if (value == null) {
079                            objectOutput.writeUTF(StringPool.BLANK);
080                    }
081                    else {
082                            objectOutput.writeUTF(value);
083                    }
084            }
085    
086            public long classNameId;
087            public String value;
088    }