001// -------------------------------------------------------------------------------- 002// Copyright 2002-2024 Echo Three, LLC 003// 004// Licensed under the Apache License, Version 2.0 (the "License"); 005// you may not use this file except in compliance with the License. 006// You may obtain a copy of the License at 007// 008// http://www.apache.org/licenses/LICENSE-2.0 009// 010// Unless required by applicable law or agreed to in writing, software 011// distributed under the License is distributed on an "AS IS" BASIS, 012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013// See the License for the specific language governing permissions and 014// limitations under the License. 015// -------------------------------------------------------------------------------- 016// Generated File -- DO NOT EDIT BY HAND 017// -------------------------------------------------------------------------------- 018 019/** 020 * ContentPageAreaBlobValue.java 021 */ 022 023package com.echothree.model.data.content.server.value; 024 025import com.echothree.model.data.content.common.pk.ContentPageAreaBlobPK; 026 027import com.echothree.model.data.content.server.factory.ContentPageAreaBlobFactory; 028 029import com.echothree.model.data.content.common.pk.ContentPageAreaDetailPK; 030 031import com.echothree.util.common.exception.PersistenceCloneException; 032import com.echothree.util.common.exception.PersistenceNotNullException; 033 034import com.echothree.util.server.persistence.BaseValue; 035 036import java.io.Serializable; 037 038import com.echothree.util.common.persistence.type.ByteArray; 039 040public class ContentPageAreaBlobValue 041 extends BaseValue<ContentPageAreaBlobPK> 042 implements Cloneable, Serializable { 043 044 private ContentPageAreaDetailPK contentPageAreaDetailPK; 045 private boolean contentPageAreaDetailPKHasBeenModified = false; 046 private ByteArray blob; 047 private boolean blobHasBeenModified = false; 048 049 private transient Integer _hashCode = null; 050 private transient String _stringValue = null; 051 052 private void constructFields(ContentPageAreaDetailPK contentPageAreaDetailPK, ByteArray blob) 053 throws PersistenceNotNullException { 054 checkForNull(contentPageAreaDetailPK); 055 this.contentPageAreaDetailPK = contentPageAreaDetailPK; 056 checkForNull(blob); 057 this.blob = blob; 058 } 059 060 /** Creates a new instance of ContentPageAreaBlobValue */ 061 public ContentPageAreaBlobValue(ContentPageAreaBlobPK contentPageAreaBlobPK, ContentPageAreaDetailPK contentPageAreaDetailPK, ByteArray blob) 062 throws PersistenceNotNullException { 063 super(contentPageAreaBlobPK); 064 constructFields(contentPageAreaDetailPK, blob); 065 } 066 067 /** Creates a new instance of ContentPageAreaBlobValue */ 068 public ContentPageAreaBlobValue(ContentPageAreaDetailPK contentPageAreaDetailPK, ByteArray blob) 069 throws PersistenceNotNullException { 070 super(); 071 constructFields(contentPageAreaDetailPK, blob); 072 } 073 074 @Override 075 public ContentPageAreaBlobFactory getBaseFactoryInstance() { 076 return ContentPageAreaBlobFactory.getInstance(); 077 } 078 079 @Override 080 public ContentPageAreaBlobValue clone() { 081 Object result; 082 083 try { 084 result = super.clone(); 085 } catch (CloneNotSupportedException cnse) { 086 // This shouldn't happen, fail when it does. 087 throw new PersistenceCloneException(cnse); 088 } 089 090 return (ContentPageAreaBlobValue)result; 091 } 092 093 @Override 094 public ContentPageAreaBlobPK getPrimaryKey() { 095 if(_primaryKey == null) { 096 _primaryKey = new ContentPageAreaBlobPK(entityId); 097 } 098 099 return _primaryKey; 100 } 101 102 private void clearHashAndString() { 103 _hashCode = null; 104 _stringValue = null; 105 } 106 107 @Override 108 public int hashCode() { 109 if(_hashCode == null) { 110 int hashCode = 17; 111 112 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 113 114 hashCode = 37 * hashCode + ((contentPageAreaDetailPK != null) ? contentPageAreaDetailPK.hashCode() : 0); 115 116 _hashCode = hashCode; 117 } 118 119 return _hashCode; 120 } 121 122 @Override 123 public String toString() { 124 if(_stringValue == null) { 125 StringBuilder stringValue = new StringBuilder("{"); 126 127 stringValue.append("entityId=").append(getEntityId()); 128 129 stringValue.append(", contentPageAreaDetailPK=").append(getContentPageAreaDetailPK()); 130 131 stringValue.append('}'); 132 133 _stringValue = stringValue.toString(); 134 } 135 return _stringValue; 136 } 137 138 @Override 139 public boolean equals(Object other) { 140 if(this == other) 141 return true; 142 143 if(!hasIdentity()) 144 return false; 145 146 if(other instanceof ContentPageAreaBlobValue) { 147 ContentPageAreaBlobValue that = (ContentPageAreaBlobValue)other; 148 149 if(!that.hasIdentity()) 150 return false; 151 152 Long thisEntityId = getEntityId(); 153 Long thatEntityId = that.getEntityId(); 154 155 boolean objectsEqual = thisEntityId.equals(thatEntityId); 156 if(objectsEqual) 157 objectsEqual = objectsEqual && isIdentical(that); 158 159 return objectsEqual; 160 } else { 161 return false; 162 } 163 } 164 165 public boolean isIdentical(Object other) { 166 if(other instanceof ContentPageAreaBlobValue) { 167 ContentPageAreaBlobValue that = (ContentPageAreaBlobValue)other; 168 boolean objectsEqual = true; 169 170 171 if(objectsEqual) { 172 ContentPageAreaDetailPK thisContentPageAreaDetailPK = getContentPageAreaDetailPK(); 173 ContentPageAreaDetailPK thatContentPageAreaDetailPK = that.getContentPageAreaDetailPK(); 174 175 if(thisContentPageAreaDetailPK == null) { 176 objectsEqual = objectsEqual && (thatContentPageAreaDetailPK == null); 177 } else { 178 objectsEqual = objectsEqual && thisContentPageAreaDetailPK.equals(thatContentPageAreaDetailPK); 179 } 180 } 181 182 if(objectsEqual) { 183 ByteArray thisBlob = getBlob(); 184 ByteArray thatBlob = that.getBlob(); 185 186 if(thisBlob == null) { 187 objectsEqual = objectsEqual && (thatBlob == null); 188 } else { 189 objectsEqual = objectsEqual && thisBlob.equals(thatBlob); 190 } 191 } 192 193 return objectsEqual; 194 } else { 195 return false; 196 } 197 } 198 199 @Override 200 public boolean hasBeenModified() { 201 return contentPageAreaDetailPKHasBeenModified || blobHasBeenModified; 202 } 203 204 @Override 205 public void clearHasBeenModified() { 206 contentPageAreaDetailPKHasBeenModified = false; 207 blobHasBeenModified = false; 208 } 209 210 public ContentPageAreaDetailPK getContentPageAreaDetailPK() { 211 return contentPageAreaDetailPK; 212 } 213 214 public void setContentPageAreaDetailPK(ContentPageAreaDetailPK contentPageAreaDetailPK) 215 throws PersistenceNotNullException { 216 checkForNull(contentPageAreaDetailPK); 217 218 boolean update = true; 219 220 if(this.contentPageAreaDetailPK != null) { 221 if(this.contentPageAreaDetailPK.equals(contentPageAreaDetailPK)) { 222 update = false; 223 } 224 } else if(contentPageAreaDetailPK == null) { 225 update = false; 226 } 227 228 if(update) { 229 this.contentPageAreaDetailPK = contentPageAreaDetailPK; 230 contentPageAreaDetailPKHasBeenModified = true; 231 clearHashAndString(); 232 } 233 } 234 235 public boolean getContentPageAreaDetailPKHasBeenModified() { 236 return contentPageAreaDetailPKHasBeenModified; 237 } 238 239 public ByteArray getBlob() { 240 return blob; 241 } 242 243 public void setBlob(ByteArray blob) 244 throws PersistenceNotNullException { 245 checkForNull(blob); 246 247 boolean update = true; 248 249 if(this.blob != null) { 250 if(this.blob.equals(blob)) { 251 update = false; 252 } 253 } else if(blob == null) { 254 update = false; 255 } 256 257 if(update) { 258 this.blob = blob; 259 blobHasBeenModified = true; 260 clearHashAndString(); 261 } 262 } 263 264 public boolean getBlobHasBeenModified() { 265 return blobHasBeenModified; 266 } 267 268}