001
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.Role;
021
022 import java.io.Externalizable;
023 import java.io.IOException;
024 import java.io.ObjectInput;
025 import java.io.ObjectOutput;
026
027
034 public class RoleCacheModel implements CacheModel<Role>, Externalizable {
035 @Override
036 public String toString() {
037 StringBundler sb = new StringBundler(19);
038
039 sb.append("{roleId=");
040 sb.append(roleId);
041 sb.append(", companyId=");
042 sb.append(companyId);
043 sb.append(", classNameId=");
044 sb.append(classNameId);
045 sb.append(", classPK=");
046 sb.append(classPK);
047 sb.append(", name=");
048 sb.append(name);
049 sb.append(", title=");
050 sb.append(title);
051 sb.append(", description=");
052 sb.append(description);
053 sb.append(", type=");
054 sb.append(type);
055 sb.append(", subtype=");
056 sb.append(subtype);
057 sb.append("}");
058
059 return sb.toString();
060 }
061
062 public Role toEntityModel() {
063 RoleImpl roleImpl = new RoleImpl();
064
065 roleImpl.setRoleId(roleId);
066 roleImpl.setCompanyId(companyId);
067 roleImpl.setClassNameId(classNameId);
068 roleImpl.setClassPK(classPK);
069
070 if (name == null) {
071 roleImpl.setName(StringPool.BLANK);
072 }
073 else {
074 roleImpl.setName(name);
075 }
076
077 if (title == null) {
078 roleImpl.setTitle(StringPool.BLANK);
079 }
080 else {
081 roleImpl.setTitle(title);
082 }
083
084 if (description == null) {
085 roleImpl.setDescription(StringPool.BLANK);
086 }
087 else {
088 roleImpl.setDescription(description);
089 }
090
091 roleImpl.setType(type);
092
093 if (subtype == null) {
094 roleImpl.setSubtype(StringPool.BLANK);
095 }
096 else {
097 roleImpl.setSubtype(subtype);
098 }
099
100 roleImpl.resetOriginalValues();
101
102 return roleImpl;
103 }
104
105 public void readExternal(ObjectInput objectInput) throws IOException {
106 roleId = objectInput.readLong();
107 companyId = objectInput.readLong();
108 classNameId = objectInput.readLong();
109 classPK = objectInput.readLong();
110 name = objectInput.readUTF();
111 title = objectInput.readUTF();
112 description = objectInput.readUTF();
113 type = objectInput.readInt();
114 subtype = objectInput.readUTF();
115 }
116
117 public void writeExternal(ObjectOutput objectOutput)
118 throws IOException {
119 objectOutput.writeLong(roleId);
120 objectOutput.writeLong(companyId);
121 objectOutput.writeLong(classNameId);
122 objectOutput.writeLong(classPK);
123
124 if (name == null) {
125 objectOutput.writeUTF(StringPool.BLANK);
126 }
127 else {
128 objectOutput.writeUTF(name);
129 }
130
131 if (title == null) {
132 objectOutput.writeUTF(StringPool.BLANK);
133 }
134 else {
135 objectOutput.writeUTF(title);
136 }
137
138 if (description == null) {
139 objectOutput.writeUTF(StringPool.BLANK);
140 }
141 else {
142 objectOutput.writeUTF(description);
143 }
144
145 objectOutput.writeInt(type);
146
147 if (subtype == null) {
148 objectOutput.writeUTF(StringPool.BLANK);
149 }
150 else {
151 objectOutput.writeUTF(subtype);
152 }
153 }
154
155 public long roleId;
156 public long companyId;
157 public long classNameId;
158 public long classPK;
159 public String name;
160 public String title;
161 public String description;
162 public int type;
163 public String subtype;
164 }