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 * 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 StringBuilder stringValue = new StringBuilder("{"); 140 141 stringValue.append("entityId=").append(getEntityId()); 142 143 stringValue.append(", contactMechanismPurposeName=").append(getContactMechanismPurposeName()); 144 stringValue.append(", contactMechanismTypePK=").append(getContactMechanismTypePK()); 145 stringValue.append(", eventSubscriber=").append(getEventSubscriber()); 146 stringValue.append(", isDefault=").append(getIsDefault()); 147 stringValue.append(", sortOrder=").append(getSortOrder()); 148 149 stringValue.append('}'); 150 151 _stringValue = stringValue.toString(); 152 } 153 return _stringValue; 154 } 155 156 @Override 157 public boolean equals(Object other) { 158 if(this == other) 159 return true; 160 161 if(!hasIdentity()) 162 return false; 163 164 if(other instanceof ContactMechanismPurposeValue) { 165 ContactMechanismPurposeValue that = (ContactMechanismPurposeValue)other; 166 167 if(!that.hasIdentity()) 168 return false; 169 170 Long thisEntityId = getEntityId(); 171 Long thatEntityId = that.getEntityId(); 172 173 boolean objectsEqual = thisEntityId.equals(thatEntityId); 174 if(objectsEqual) 175 objectsEqual = objectsEqual && isIdentical(that); 176 177 return objectsEqual; 178 } else { 179 return false; 180 } 181 } 182 183 public boolean isIdentical(Object other) { 184 if(other instanceof ContactMechanismPurposeValue) { 185 ContactMechanismPurposeValue that = (ContactMechanismPurposeValue)other; 186 boolean objectsEqual = true; 187 188 189 if(objectsEqual) { 190 String thisContactMechanismPurposeName = getContactMechanismPurposeName(); 191 String thatContactMechanismPurposeName = that.getContactMechanismPurposeName(); 192 193 if(thisContactMechanismPurposeName == null) { 194 objectsEqual = objectsEqual && (thatContactMechanismPurposeName == null); 195 } else { 196 objectsEqual = objectsEqual && thisContactMechanismPurposeName.equals(thatContactMechanismPurposeName); 197 } 198 } 199 200 if(objectsEqual) { 201 ContactMechanismTypePK thisContactMechanismTypePK = getContactMechanismTypePK(); 202 ContactMechanismTypePK thatContactMechanismTypePK = that.getContactMechanismTypePK(); 203 204 if(thisContactMechanismTypePK == null) { 205 objectsEqual = objectsEqual && (thatContactMechanismTypePK == null); 206 } else { 207 objectsEqual = objectsEqual && thisContactMechanismTypePK.equals(thatContactMechanismTypePK); 208 } 209 } 210 211 if(objectsEqual) { 212 Boolean thisEventSubscriber = getEventSubscriber(); 213 Boolean thatEventSubscriber = that.getEventSubscriber(); 214 215 if(thisEventSubscriber == null) { 216 objectsEqual = objectsEqual && (thatEventSubscriber == null); 217 } else { 218 objectsEqual = objectsEqual && thisEventSubscriber.equals(thatEventSubscriber); 219 } 220 } 221 222 if(objectsEqual) { 223 Boolean thisIsDefault = getIsDefault(); 224 Boolean thatIsDefault = that.getIsDefault(); 225 226 if(thisIsDefault == null) { 227 objectsEqual = objectsEqual && (thatIsDefault == null); 228 } else { 229 objectsEqual = objectsEqual && thisIsDefault.equals(thatIsDefault); 230 } 231 } 232 233 if(objectsEqual) { 234 Integer thisSortOrder = getSortOrder(); 235 Integer thatSortOrder = that.getSortOrder(); 236 237 if(thisSortOrder == null) { 238 objectsEqual = objectsEqual && (thatSortOrder == null); 239 } else { 240 objectsEqual = objectsEqual && thisSortOrder.equals(thatSortOrder); 241 } 242 } 243 244 return objectsEqual; 245 } else { 246 return false; 247 } 248 } 249 250 @Override 251 public boolean hasBeenModified() { 252 return contactMechanismPurposeNameHasBeenModified || contactMechanismTypePKHasBeenModified || eventSubscriberHasBeenModified || isDefaultHasBeenModified || sortOrderHasBeenModified; 253 } 254 255 @Override 256 public void clearHasBeenModified() { 257 contactMechanismPurposeNameHasBeenModified = false; 258 contactMechanismTypePKHasBeenModified = false; 259 eventSubscriberHasBeenModified = false; 260 isDefaultHasBeenModified = false; 261 sortOrderHasBeenModified = false; 262 } 263 264 public String getContactMechanismPurposeName() { 265 return contactMechanismPurposeName; 266 } 267 268 public void setContactMechanismPurposeName(String contactMechanismPurposeName) 269 throws PersistenceNotNullException { 270 checkForNull(contactMechanismPurposeName); 271 272 boolean update = true; 273 274 if(this.contactMechanismPurposeName != null) { 275 if(this.contactMechanismPurposeName.equals(contactMechanismPurposeName)) { 276 update = false; 277 } 278 } else if(contactMechanismPurposeName == null) { 279 update = false; 280 } 281 282 if(update) { 283 this.contactMechanismPurposeName = contactMechanismPurposeName; 284 contactMechanismPurposeNameHasBeenModified = true; 285 clearHashAndString(); 286 } 287 } 288 289 public boolean getContactMechanismPurposeNameHasBeenModified() { 290 return contactMechanismPurposeNameHasBeenModified; 291 } 292 293 public ContactMechanismTypePK getContactMechanismTypePK() { 294 return contactMechanismTypePK; 295 } 296 297 public void setContactMechanismTypePK(ContactMechanismTypePK contactMechanismTypePK) 298 throws PersistenceNotNullException { 299 checkForNull(contactMechanismTypePK); 300 301 boolean update = true; 302 303 if(this.contactMechanismTypePK != null) { 304 if(this.contactMechanismTypePK.equals(contactMechanismTypePK)) { 305 update = false; 306 } 307 } else if(contactMechanismTypePK == null) { 308 update = false; 309 } 310 311 if(update) { 312 this.contactMechanismTypePK = contactMechanismTypePK; 313 contactMechanismTypePKHasBeenModified = true; 314 clearHashAndString(); 315 } 316 } 317 318 public boolean getContactMechanismTypePKHasBeenModified() { 319 return contactMechanismTypePKHasBeenModified; 320 } 321 322 public Boolean getEventSubscriber() { 323 return eventSubscriber; 324 } 325 326 public void setEventSubscriber(Boolean eventSubscriber) 327 throws PersistenceNotNullException { 328 checkForNull(eventSubscriber); 329 330 boolean update = true; 331 332 if(this.eventSubscriber != null) { 333 if(this.eventSubscriber.equals(eventSubscriber)) { 334 update = false; 335 } 336 } else if(eventSubscriber == null) { 337 update = false; 338 } 339 340 if(update) { 341 this.eventSubscriber = eventSubscriber; 342 eventSubscriberHasBeenModified = true; 343 clearHashAndString(); 344 } 345 } 346 347 public boolean getEventSubscriberHasBeenModified() { 348 return eventSubscriberHasBeenModified; 349 } 350 351 public Boolean getIsDefault() { 352 return isDefault; 353 } 354 355 public void setIsDefault(Boolean isDefault) 356 throws PersistenceNotNullException { 357 checkForNull(isDefault); 358 359 boolean update = true; 360 361 if(this.isDefault != null) { 362 if(this.isDefault.equals(isDefault)) { 363 update = false; 364 } 365 } else if(isDefault == null) { 366 update = false; 367 } 368 369 if(update) { 370 this.isDefault = isDefault; 371 isDefaultHasBeenModified = true; 372 clearHashAndString(); 373 } 374 } 375 376 public boolean getIsDefaultHasBeenModified() { 377 return isDefaultHasBeenModified; 378 } 379 380 public Integer getSortOrder() { 381 return sortOrder; 382 } 383 384 public void setSortOrder(Integer sortOrder) 385 throws PersistenceNotNullException { 386 checkForNull(sortOrder); 387 388 boolean update = true; 389 390 if(this.sortOrder != null) { 391 if(this.sortOrder.equals(sortOrder)) { 392 update = false; 393 } 394 } else if(sortOrder == null) { 395 update = false; 396 } 397 398 if(update) { 399 this.sortOrder = sortOrder; 400 sortOrderHasBeenModified = true; 401 clearHashAndString(); 402 } 403 } 404 405 public boolean getSortOrderHasBeenModified() { 406 return sortOrderHasBeenModified; 407 } 408 409}