001// -------------------------------------------------------------------------------- 002// Copyright 2002-2026 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 javax.annotation.Nonnull; 039import javax.annotation.Nullable; 040 041import com.echothree.util.common.persistence.type.ByteArray; 042 043public class ContentPageAreaBlobValue 044 extends BaseValue<ContentPageAreaBlobPK> 045 implements Cloneable, Serializable { 046 047 private ContentPageAreaDetailPK contentPageAreaDetailPK; 048 private boolean contentPageAreaDetailPKHasBeenModified = false; 049 private ByteArray blob; 050 private boolean blobHasBeenModified = false; 051 052 private transient Integer _hashCode = null; 053 private transient String _stringValue = null; 054 055 private void constructFields(ContentPageAreaDetailPK contentPageAreaDetailPK, ByteArray blob) 056 throws PersistenceNotNullException { 057 checkForNull(contentPageAreaDetailPK); 058 this.contentPageAreaDetailPK = contentPageAreaDetailPK; 059 checkForNull(blob); 060 this.blob = blob; 061 } 062 063 /** Creates a new instance of ContentPageAreaBlobValue */ 064 public ContentPageAreaBlobValue(ContentPageAreaBlobPK contentPageAreaBlobPK, ContentPageAreaDetailPK contentPageAreaDetailPK, ByteArray blob) 065 throws PersistenceNotNullException { 066 super(contentPageAreaBlobPK); 067 constructFields(contentPageAreaDetailPK, blob); 068 } 069 070 /** Creates a new instance of ContentPageAreaBlobValue */ 071 public ContentPageAreaBlobValue(ContentPageAreaDetailPK contentPageAreaDetailPK, ByteArray blob) 072 throws PersistenceNotNullException { 073 super(); 074 constructFields(contentPageAreaDetailPK, blob); 075 } 076 077 @Override 078 @Nonnull 079 public ContentPageAreaBlobFactory getBaseFactoryInstance() { 080 return ContentPageAreaBlobFactory.getInstance(); 081 } 082 083 @Override 084 @Nonnull 085 public ContentPageAreaBlobValue clone() { 086 Object result; 087 088 try { 089 result = super.clone(); 090 } catch (CloneNotSupportedException cnse) { 091 // This shouldn't happen, fail when it does. 092 throw new PersistenceCloneException(cnse); 093 } 094 095 return (ContentPageAreaBlobValue)result; 096 } 097 098 @Override 099 @Nonnull 100 public ContentPageAreaBlobPK getPrimaryKey() { 101 if(_primaryKey == null) { 102 _primaryKey = new ContentPageAreaBlobPK(entityId); 103 } 104 105 return _primaryKey; 106 } 107 108 private void clearHashAndString() { 109 _hashCode = null; 110 _stringValue = null; 111 } 112 113 @Override 114 public int hashCode() { 115 if(_hashCode == null) { 116 int hashCode = 17; 117 118 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 119 120 hashCode = 37 * hashCode + ((contentPageAreaDetailPK != null) ? contentPageAreaDetailPK.hashCode() : 0); 121 122 _hashCode = hashCode; 123 } 124 125 return _hashCode; 126 } 127 128 @Override 129 @Nonnull 130 public String toString() { 131 if(_stringValue == null) { 132 _stringValue = "{" + 133 "entityId=" + getEntityId() + 134 ", contentPageAreaDetailPK=" + getContentPageAreaDetailPK() + 135 "}"; 136 } 137 return _stringValue; 138 } 139 140 @Override 141 public boolean equals(Object other) { 142 if(this == other) 143 return true; 144 145 if(!hasIdentity()) 146 return false; 147 148 if(other instanceof ContentPageAreaBlobValue that) { 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 = 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 that) { 167 boolean objectsEqual = true; 168 169 170 if(objectsEqual) { 171 ContentPageAreaDetailPK thisContentPageAreaDetailPK = getContentPageAreaDetailPK(); 172 ContentPageAreaDetailPK thatContentPageAreaDetailPK = that.getContentPageAreaDetailPK(); 173 174 if(thisContentPageAreaDetailPK == null) { 175 objectsEqual = objectsEqual && (thatContentPageAreaDetailPK == null); 176 } else { 177 objectsEqual = objectsEqual && thisContentPageAreaDetailPK.equals(thatContentPageAreaDetailPK); 178 } 179 } 180 181 if(objectsEqual) { 182 ByteArray thisBlob = getBlob(); 183 ByteArray thatBlob = that.getBlob(); 184 185 if(thisBlob == null) { 186 objectsEqual = objectsEqual && (thatBlob == null); 187 } else { 188 objectsEqual = objectsEqual && thisBlob.equals(thatBlob); 189 } 190 } 191 192 return objectsEqual; 193 } else { 194 return false; 195 } 196 } 197 198 @Override 199 public boolean hasBeenModified() { 200 return contentPageAreaDetailPKHasBeenModified || blobHasBeenModified; 201 } 202 203 @Override 204 public void clearHasBeenModified() { 205 contentPageAreaDetailPKHasBeenModified = false; 206 blobHasBeenModified = false; 207 } 208 209 @Nonnull 210 public ContentPageAreaDetailPK getContentPageAreaDetailPK() { 211 return contentPageAreaDetailPK; 212 } 213 214 public void setContentPageAreaDetailPK(@Nonnull 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 @Nonnull 240 public ByteArray getBlob() { 241 return blob; 242 } 243 244 public void setBlob(@Nonnull ByteArray blob) 245 throws PersistenceNotNullException { 246 checkForNull(blob); 247 248 boolean update = true; 249 250 if(this.blob != null) { 251 if(this.blob.equals(blob)) { 252 update = false; 253 } 254 } else if(blob == null) { 255 update = false; 256 } 257 258 if(update) { 259 this.blob = blob; 260 blobHasBeenModified = true; 261 clearHashAndString(); 262 } 263 } 264 265 public boolean getBlobHasBeenModified() { 266 return blobHasBeenModified; 267 } 268 269}