001
014
015 package com.liferay.portlet.softwarecatalog.model.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.util.StringBundler;
020 import com.liferay.portal.kernel.util.StringPool;
021 import com.liferay.portal.model.CacheModel;
022
023 import com.liferay.portlet.softwarecatalog.model.SCLicense;
024
025 import java.io.Externalizable;
026 import java.io.IOException;
027 import java.io.ObjectInput;
028 import java.io.ObjectOutput;
029
030
037 @ProviderType
038 public class SCLicenseCacheModel implements CacheModel<SCLicense>,
039 Externalizable {
040 @Override
041 public String toString() {
042 StringBundler sb = new StringBundler(13);
043
044 sb.append("{licenseId=");
045 sb.append(licenseId);
046 sb.append(", name=");
047 sb.append(name);
048 sb.append(", url=");
049 sb.append(url);
050 sb.append(", openSource=");
051 sb.append(openSource);
052 sb.append(", active=");
053 sb.append(active);
054 sb.append(", recommended=");
055 sb.append(recommended);
056 sb.append("}");
057
058 return sb.toString();
059 }
060
061 @Override
062 public SCLicense toEntityModel() {
063 SCLicenseImpl scLicenseImpl = new SCLicenseImpl();
064
065 scLicenseImpl.setLicenseId(licenseId);
066
067 if (name == null) {
068 scLicenseImpl.setName(StringPool.BLANK);
069 }
070 else {
071 scLicenseImpl.setName(name);
072 }
073
074 if (url == null) {
075 scLicenseImpl.setUrl(StringPool.BLANK);
076 }
077 else {
078 scLicenseImpl.setUrl(url);
079 }
080
081 scLicenseImpl.setOpenSource(openSource);
082 scLicenseImpl.setActive(active);
083 scLicenseImpl.setRecommended(recommended);
084
085 scLicenseImpl.resetOriginalValues();
086
087 return scLicenseImpl;
088 }
089
090 @Override
091 public void readExternal(ObjectInput objectInput) throws IOException {
092 licenseId = objectInput.readLong();
093 name = objectInput.readUTF();
094 url = objectInput.readUTF();
095 openSource = objectInput.readBoolean();
096 active = objectInput.readBoolean();
097 recommended = objectInput.readBoolean();
098 }
099
100 @Override
101 public void writeExternal(ObjectOutput objectOutput)
102 throws IOException {
103 objectOutput.writeLong(licenseId);
104
105 if (name == null) {
106 objectOutput.writeUTF(StringPool.BLANK);
107 }
108 else {
109 objectOutput.writeUTF(name);
110 }
111
112 if (url == null) {
113 objectOutput.writeUTF(StringPool.BLANK);
114 }
115 else {
116 objectOutput.writeUTF(url);
117 }
118
119 objectOutput.writeBoolean(openSource);
120 objectOutput.writeBoolean(active);
121 objectOutput.writeBoolean(recommended);
122 }
123
124 public long licenseId;
125 public String name;
126 public String url;
127 public boolean openSource;
128 public boolean active;
129 public boolean recommended;
130 }