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 * QueuedSubscriberEventValue.java 021 */ 022 023package com.echothree.model.data.core.server.value; 024 025import com.echothree.model.data.core.common.pk.QueuedSubscriberEventPK; 026 027import com.echothree.model.data.core.server.factory.QueuedSubscriberEventFactory; 028 029import com.echothree.model.data.core.common.pk.EventSubscriberPK; 030import com.echothree.model.data.core.common.pk.EventPK; 031 032import com.echothree.util.common.exception.PersistenceCloneException; 033import com.echothree.util.common.exception.PersistenceNotNullException; 034 035import com.echothree.util.server.persistence.BaseValue; 036 037import java.io.Serializable; 038 039public class QueuedSubscriberEventValue 040 extends BaseValue<QueuedSubscriberEventPK> 041 implements Cloneable, Serializable { 042 043 private EventSubscriberPK eventSubscriberPK; 044 private boolean eventSubscriberPKHasBeenModified = false; 045 private EventPK eventPK; 046 private boolean eventPKHasBeenModified = false; 047 048 private transient Integer _hashCode = null; 049 private transient String _stringValue = null; 050 051 private void constructFields(EventSubscriberPK eventSubscriberPK, EventPK eventPK) 052 throws PersistenceNotNullException { 053 checkForNull(eventSubscriberPK); 054 this.eventSubscriberPK = eventSubscriberPK; 055 checkForNull(eventPK); 056 this.eventPK = eventPK; 057 } 058 059 /** Creates a new instance of QueuedSubscriberEventValue */ 060 public QueuedSubscriberEventValue(QueuedSubscriberEventPK queuedSubscriberEventPK, EventSubscriberPK eventSubscriberPK, EventPK eventPK) 061 throws PersistenceNotNullException { 062 super(queuedSubscriberEventPK); 063 constructFields(eventSubscriberPK, eventPK); 064 } 065 066 /** Creates a new instance of QueuedSubscriberEventValue */ 067 public QueuedSubscriberEventValue(EventSubscriberPK eventSubscriberPK, EventPK eventPK) 068 throws PersistenceNotNullException { 069 super(); 070 constructFields(eventSubscriberPK, eventPK); 071 } 072 073 @Override 074 public QueuedSubscriberEventFactory getBaseFactoryInstance() { 075 return QueuedSubscriberEventFactory.getInstance(); 076 } 077 078 @Override 079 public QueuedSubscriberEventValue clone() { 080 Object result; 081 082 try { 083 result = super.clone(); 084 } catch (CloneNotSupportedException cnse) { 085 // This shouldn't happen, fail when it does. 086 throw new PersistenceCloneException(cnse); 087 } 088 089 return (QueuedSubscriberEventValue)result; 090 } 091 092 @Override 093 public QueuedSubscriberEventPK getPrimaryKey() { 094 if(_primaryKey == null) { 095 _primaryKey = new QueuedSubscriberEventPK(entityId); 096 } 097 098 return _primaryKey; 099 } 100 101 private void clearHashAndString() { 102 _hashCode = null; 103 _stringValue = null; 104 } 105 106 @Override 107 public int hashCode() { 108 if(_hashCode == null) { 109 int hashCode = 17; 110 111 hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0); 112 113 hashCode = 37 * hashCode + ((eventSubscriberPK != null) ? eventSubscriberPK.hashCode() : 0); 114 hashCode = 37 * hashCode + ((eventPK != null) ? eventPK.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(", eventSubscriberPK=").append(getEventSubscriberPK()); 130 stringValue.append(", eventPK=").append(getEventPK()); 131 132 stringValue.append('}'); 133 134 _stringValue = stringValue.toString(); 135 } 136 return _stringValue; 137 } 138 139 @Override 140 public boolean equals(Object other) { 141 if(this == other) 142 return true; 143 144 if(!hasIdentity()) 145 return false; 146 147 if(other instanceof QueuedSubscriberEventValue) { 148 QueuedSubscriberEventValue that = (QueuedSubscriberEventValue)other; 149 150 if(!that.hasIdentity()) 151 return false; 152 153 Long thisEntityId = getEntityId(); 154 Long thatEntityId = that.getEntityId(); 155 156 boolean objectsEqual = thisEntityId.equals(thatEntityId); 157 if(objectsEqual) 158 objectsEqual = objectsEqual && isIdentical(that); 159 160 return objectsEqual; 161 } else { 162 return false; 163 } 164 } 165 166 public boolean isIdentical(Object other) { 167 if(other instanceof QueuedSubscriberEventValue) { 168 QueuedSubscriberEventValue that = (QueuedSubscriberEventValue)other; 169 boolean objectsEqual = true; 170 171 172 if(objectsEqual) { 173 EventSubscriberPK thisEventSubscriberPK = getEventSubscriberPK(); 174 EventSubscriberPK thatEventSubscriberPK = that.getEventSubscriberPK(); 175 176 if(thisEventSubscriberPK == null) { 177 objectsEqual = objectsEqual && (thatEventSubscriberPK == null); 178 } else { 179 objectsEqual = objectsEqual && thisEventSubscriberPK.equals(thatEventSubscriberPK); 180 } 181 } 182 183 if(objectsEqual) { 184 EventPK thisEventPK = getEventPK(); 185 EventPK thatEventPK = that.getEventPK(); 186 187 if(thisEventPK == null) { 188 objectsEqual = objectsEqual && (thatEventPK == null); 189 } else { 190 objectsEqual = objectsEqual && thisEventPK.equals(thatEventPK); 191 } 192 } 193 194 return objectsEqual; 195 } else { 196 return false; 197 } 198 } 199 200 @Override 201 public boolean hasBeenModified() { 202 return eventSubscriberPKHasBeenModified || eventPKHasBeenModified; 203 } 204 205 @Override 206 public void clearHasBeenModified() { 207 eventSubscriberPKHasBeenModified = false; 208 eventPKHasBeenModified = false; 209 } 210 211 public EventSubscriberPK getEventSubscriberPK() { 212 return eventSubscriberPK; 213 } 214 215 public void setEventSubscriberPK(EventSubscriberPK eventSubscriberPK) 216 throws PersistenceNotNullException { 217 checkForNull(eventSubscriberPK); 218 219 boolean update = true; 220 221 if(this.eventSubscriberPK != null) { 222 if(this.eventSubscriberPK.equals(eventSubscriberPK)) { 223 update = false; 224 } 225 } else if(eventSubscriberPK == null) { 226 update = false; 227 } 228 229 if(update) { 230 this.eventSubscriberPK = eventSubscriberPK; 231 eventSubscriberPKHasBeenModified = true; 232 clearHashAndString(); 233 } 234 } 235 236 public boolean getEventSubscriberPKHasBeenModified() { 237 return eventSubscriberPKHasBeenModified; 238 } 239 240 public EventPK getEventPK() { 241 return eventPK; 242 } 243 244 public void setEventPK(EventPK eventPK) 245 throws PersistenceNotNullException { 246 checkForNull(eventPK); 247 248 boolean update = true; 249 250 if(this.eventPK != null) { 251 if(this.eventPK.equals(eventPK)) { 252 update = false; 253 } 254 } else if(eventPK == null) { 255 update = false; 256 } 257 258 if(update) { 259 this.eventPK = eventPK; 260 eventPKHasBeenModified = true; 261 clearHashAndString(); 262 } 263 } 264 265 public boolean getEventPKHasBeenModified() { 266 return eventPKHasBeenModified; 267 } 268 269}