001// -------------------------------------------------------------------------------- 002// Copyright 2002-2025 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 * ContactMechanismPurposeValue.java 021 */ 022 023package com.echothree.model.data.contact.server.value; 024 025import com.echothree.model.data.contact.common.pk.ContactMechanismPurposePK; 026 027import com.echothree.model.data.contact.server.factory.ContactMechanismPurposeFactory; 028 029import com.echothree.model.data.contact.common.pk.ContactMechanismTypePK; 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 038public class ContactMechanismPurposeValue 039 extends BaseValue<ContactMechanismPurposePK> 040 implements Cloneable, Serializable { 041 042 private String contactMechanismPurposeName; 043 private boolean contactMechanismPurposeNameHasBeenModified = false; 044 private ContactMechanismTypePK contactMechanismTypePK; 045 private boolean contactMechanismTypePKHasBeenModified = false; 046 private Boolean eventSubscriber; 047 private boolean eventSubscriberHasBeenModified = false; 048 private Boolean isDefault; 049 private boolean isDefaultHasBeenModified = false; 050 private Integer sortOrder; 051 private boolean sortOrderHasBeenModified = false; 052 053 private transient Integer _hashCode = null; 054 private transient String _stringValue = null; 055 056 private void constructFields(String contactMechanismPurposeName, ContactMechanismTypePK contactMechanismTypePK, Boolean eventSubscriber, Boolean isDefault, Integer sortOrder) 057 throws PersistenceNotNullException { 058 checkForNull(contactMechanismPurposeName); 059 this.contactMechanismPurposeName = contactMechanismPurposeName; 060 checkForNull(contactMechanismTypePK); 061 this.contactMechanismTypePK = contactMechanismTypePK; 062 checkForNull(eventSubscriber); 063 this.eventSubscriber = eventSubscriber; 064 checkForNull(isDefault); 065 this.isDefault = isDefault; 066 checkForNull(sortOrder); 067 this.sortOrder = sortOrder; 068 } 069 070 /** Creates a new instance of ContactMechanismPurposeValue */ 071 public ContactMechanismPurposeValue(ContactMechanismPurposePK contactMechanismPurposePK, String contactMechanismPurposeName, ContactMechanismTypePK contactMechanismTypePK, Boolean eventSubscriber, Boolean isDefault, Integer sortOrder) 072 throws PersistenceNotNullException { 073 super(contactMechanismPurposePK); 074 constructFields(contactMechanismPurposeName, contactMechanismTypePK, eventSubscriber, isDefault, sortOrder); 075 } 076 077 /** Creates a new instance of ContactMechanismPurposeValue */ 078 public ContactMechanismPurposeValue(String contactMechanismPurposeName, ContactMechanismTypePK contactMechanismTypePK, Boolean eventSubscriber, Boolean isDefault, Integer sortOrder) 079 throws PersistenceNotNullException { 080 super(); 081 constructFields(contactMechanismPurposeName, contactMechanismTypePK, eventSubscriber, isDefault, sortOrder); 082 } 083 084 @Override 085 public ContactMechanismPurposeFactory getBaseFactoryInstance() { 086 return ContactMechanismPurposeFactory.getInstance(); 087 } 088 089 @Override 090 public ContactMechanismPurposeValue clone() { 091 Object result; 092 093 try { 094 result = super.clone(); 095 } catch (CloneNotSupportedException cnse) { 096 // This shouldn't happen, fail when it does. 097 throw new PersistenceCloneException(cnse); 098 } 099 100 return (ContactMechanismPurposeValue)result; 101 } 102 103 @Override 104 public ContactMechanismPurposePK getPrimaryKey() { 105 if(_primaryKey == null) { 106 _primaryKey = new ContactMechanismPurposePK(entityId); 107 } 108 109 return _primaryKey; 110 } 111 112 private void clearHashAndString() { 113 _hashCode = null; 114 _stringValue = null; 115 } 116 117 @Override 118 public int hashCode() { 119 if(_hashCode == null) { 120 int hashCode = 17; 121 122 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 123 124 hashCode = 37 * hashCode + ((contactMechanismPurposeName != null) ? contactMechanismPurposeName.hashCode() : 0); 125 hashCode = 37 * hashCode + ((contactMechanismTypePK != null) ? contactMechanismTypePK.hashCode() : 0); 126 hashCode = 37 * hashCode + ((eventSubscriber != null) ? eventSubscriber.hashCode() : 0); 127 hashCode = 37 * hashCode + ((isDefault != null) ? isDefault.hashCode() : 0); 128 hashCode = 37 * hashCode + ((sortOrder != null) ? sortOrder.hashCode() : 0); 129 130 _hashCode = hashCode; 131 } 132 133 return _hashCode; 134 } 135 136 @Override 137 public String toString() { 138 if(_stringValue == null) { 139 _stringValue = "{" + 140 "entityId=" + getEntityId() + 141 ", contactMechanismPurposeName=" + getContactMechanismPurposeName() + 142 ", contactMechanismTypePK=" + getContactMechanismTypePK() + 143 ", eventSubscriber=" + getEventSubscriber() + 144 ", isDefault=" + getIsDefault() + 145 ", sortOrder=" + getSortOrder() + 146 "}"; 147 } 148 return _stringValue; 149 } 150 151 @Override 152 public boolean equals(Object other) { 153 if(this == other) 154 return true; 155 156 if(!hasIdentity()) 157 return false; 158 159 if(other instanceof ContactMechanismPurposeValue that) { 160 if(!that.hasIdentity()) 161 return false; 162 163 Long thisEntityId = getEntityId(); 164 Long thatEntityId = that.getEntityId(); 165 166 boolean objectsEqual = thisEntityId.equals(thatEntityId); 167 if(objectsEqual) 168 objectsEqual = isIdentical(that); 169 170 return objectsEqual; 171 } else { 172 return false; 173 } 174 } 175 176 public boolean isIdentical(Object other) { 177 if(other instanceof ContactMechanismPurposeValue that) { 178 boolean objectsEqual = true; 179 180 181 if(objectsEqual) { 182 String thisContactMechanismPurposeName = getContactMechanismPurposeName(); 183 String thatContactMechanismPurposeName = that.getContactMechanismPurposeName(); 184 185 if(thisContactMechanismPurposeName == null) { 186 objectsEqual = objectsEqual && (thatContactMechanismPurposeName == null); 187 } else { 188 objectsEqual = objectsEqual && thisContactMechanismPurposeName.equals(thatContactMechanismPurposeName); 189 } 190 } 191 192 if(objectsEqual) { 193 ContactMechanismTypePK thisContactMechanismTypePK = getContactMechanismTypePK(); 194 ContactMechanismTypePK thatContactMechanismTypePK = that.getContactMechanismTypePK(); 195 196 if(thisContactMechanismTypePK == null) { 197 objectsEqual = objectsEqual && (thatContactMechanismTypePK == null); 198 } else { 199 objectsEqual = objectsEqual && thisContactMechanismTypePK.equals(thatContactMechanismTypePK); 200 } 201 } 202 203 if(objectsEqual) { 204 Boolean thisEventSubscriber = getEventSubscriber(); 205 Boolean thatEventSubscriber = that.getEventSubscriber(); 206 207 if(thisEventSubscriber == null) { 208 objectsEqual = objectsEqual && (thatEventSubscriber == null); 209 } else { 210 objectsEqual = objectsEqual && thisEventSubscriber.equals(thatEventSubscriber); 211 } 212 } 213 214 if(objectsEqual) { 215 Boolean thisIsDefault = getIsDefault(); 216 Boolean thatIsDefault = that.getIsDefault(); 217 218 if(thisIsDefault == null) { 219 objectsEqual = objectsEqual && (thatIsDefault == null); 220 } else { 221 objectsEqual = objectsEqual && thisIsDefault.equals(thatIsDefault); 222 } 223 } 224 225 if(objectsEqual) { 226 Integer thisSortOrder = getSortOrder(); 227 Integer thatSortOrder = that.getSortOrder(); 228 229 if(thisSortOrder == null) { 230 objectsEqual = objectsEqual && (thatSortOrder == null); 231 } else { 232 objectsEqual = objectsEqual && thisSortOrder.equals(thatSortOrder); 233 } 234 } 235 236 return objectsEqual; 237 } else { 238 return false; 239 } 240 } 241 242 @Override 243 public boolean hasBeenModified() { 244 return contactMechanismPurposeNameHasBeenModified || contactMechanismTypePKHasBeenModified || eventSubscriberHasBeenModified || isDefaultHasBeenModified || sortOrderHasBeenModified; 245 } 246 247 @Override 248 public void clearHasBeenModified() { 249 contactMechanismPurposeNameHasBeenModified = false; 250 contactMechanismTypePKHasBeenModified = false; 251 eventSubscriberHasBeenModified = false; 252 isDefaultHasBeenModified = false; 253 sortOrderHasBeenModified = false; 254 } 255 256 public String getContactMechanismPurposeName() { 257 return contactMechanismPurposeName; 258 } 259 260 public void setContactMechanismPurposeName(String contactMechanismPurposeName) 261 throws PersistenceNotNullException { 262 checkForNull(contactMechanismPurposeName); 263 264 boolean update = true; 265 266 if(this.contactMechanismPurposeName != null) { 267 if(this.contactMechanismPurposeName.equals(contactMechanismPurposeName)) { 268 update = false; 269 } 270 } else if(contactMechanismPurposeName == null) { 271 update = false; 272 } 273 274 if(update) { 275 this.contactMechanismPurposeName = contactMechanismPurposeName; 276 contactMechanismPurposeNameHasBeenModified = true; 277 clearHashAndString(); 278 } 279 } 280 281 public boolean getContactMechanismPurposeNameHasBeenModified() { 282 return contactMechanismPurposeNameHasBeenModified; 283 } 284 285 public ContactMechanismTypePK getContactMechanismTypePK() { 286 return contactMechanismTypePK; 287 } 288 289 public void setContactMechanismTypePK(ContactMechanismTypePK contactMechanismTypePK) 290 throws PersistenceNotNullException { 291 checkForNull(contactMechanismTypePK); 292 293 boolean update = true; 294 295 if(this.contactMechanismTypePK != null) { 296 if(this.contactMechanismTypePK.equals(contactMechanismTypePK)) { 297 update = false; 298 } 299 } else if(contactMechanismTypePK == null) { 300 update = false; 301 } 302 303 if(update) { 304 this.contactMechanismTypePK = contactMechanismTypePK; 305 contactMechanismTypePKHasBeenModified = true; 306 clearHashAndString(); 307 } 308 } 309 310 public boolean getContactMechanismTypePKHasBeenModified() { 311 return contactMechanismTypePKHasBeenModified; 312 } 313 314 public Boolean getEventSubscriber() { 315 return eventSubscriber; 316 } 317 318 public void setEventSubscriber(Boolean eventSubscriber) 319 throws PersistenceNotNullException { 320 checkForNull(eventSubscriber); 321 322 boolean update = true; 323 324 if(this.eventSubscriber != null) { 325 if(this.eventSubscriber.equals(eventSubscriber)) { 326 update = false; 327 } 328 } else if(eventSubscriber == null) { 329 update = false; 330 } 331 332 if(update) { 333 this.eventSubscriber = eventSubscriber; 334 eventSubscriberHasBeenModified = true; 335 clearHashAndString(); 336 } 337 } 338 339 public boolean getEventSubscriberHasBeenModified() { 340 return eventSubscriberHasBeenModified; 341 } 342 343 public Boolean getIsDefault() { 344 return isDefault; 345 } 346 347 public void setIsDefault(Boolean isDefault) 348 throws PersistenceNotNullException { 349 checkForNull(isDefault); 350 351 boolean update = true; 352 353 if(this.isDefault != null) { 354 if(this.isDefault.equals(isDefault)) { 355 update = false; 356 } 357 } else if(isDefault == null) { 358 update = false; 359 } 360 361 if(update) { 362 this.isDefault = isDefault; 363 isDefaultHasBeenModified = true; 364 clearHashAndString(); 365 } 366 } 367 368 public boolean getIsDefaultHasBeenModified() { 369 return isDefaultHasBeenModified; 370 } 371 372 public Integer getSortOrder() { 373 return sortOrder; 374 } 375 376 public void setSortOrder(Integer sortOrder) 377 throws PersistenceNotNullException { 378 checkForNull(sortOrder); 379 380 boolean update = true; 381 382 if(this.sortOrder != null) { 383 if(this.sortOrder.equals(sortOrder)) { 384 update = false; 385 } 386 } else if(sortOrder == null) { 387 update = false; 388 } 389 390 if(update) { 391 this.sortOrder = sortOrder; 392 sortOrderHasBeenModified = true; 393 clearHashAndString(); 394 } 395 } 396 397 public boolean getSortOrderHasBeenModified() { 398 return sortOrderHasBeenModified; 399 } 400 401}