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 * 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
039import javax.annotation.Nonnull;
040import javax.annotation.Nullable;
041
042public class QueuedSubscriberEventValue
043        extends BaseValue<QueuedSubscriberEventPK>
044        implements Cloneable, Serializable {
045    
046    private EventSubscriberPK eventSubscriberPK;
047    private boolean eventSubscriberPKHasBeenModified = false;
048    private EventPK eventPK;
049    private boolean eventPKHasBeenModified = false;
050    
051    private transient Integer _hashCode = null;
052    private transient String _stringValue = null;
053    
054    private void constructFields(EventSubscriberPK eventSubscriberPK, EventPK eventPK)
055            throws PersistenceNotNullException {
056        checkForNull(eventSubscriberPK);
057        this.eventSubscriberPK = eventSubscriberPK;
058        checkForNull(eventPK);
059        this.eventPK = eventPK;
060    }
061    
062    /** Creates a new instance of QueuedSubscriberEventValue */
063    public QueuedSubscriberEventValue(QueuedSubscriberEventPK queuedSubscriberEventPK, EventSubscriberPK eventSubscriberPK, EventPK eventPK)
064            throws PersistenceNotNullException {
065        super(queuedSubscriberEventPK);
066        constructFields(eventSubscriberPK, eventPK);
067    }
068    
069    /** Creates a new instance of QueuedSubscriberEventValue */
070    public QueuedSubscriberEventValue(EventSubscriberPK eventSubscriberPK, EventPK eventPK)
071            throws PersistenceNotNullException {
072        super();
073        constructFields(eventSubscriberPK, eventPK);
074    }
075    
076    @Override
077    @Nonnull
078    public QueuedSubscriberEventFactory getBaseFactoryInstance() {
079        return QueuedSubscriberEventFactory.getInstance();
080    }
081    
082    @Override
083    @Nonnull
084    public QueuedSubscriberEventValue clone() {
085        Object result;
086        
087        try {
088            result = super.clone();
089        } catch (CloneNotSupportedException cnse) {
090            // This shouldn't happen, fail when it does.
091            throw new PersistenceCloneException(cnse);
092        }
093        
094        return (QueuedSubscriberEventValue)result;
095    }
096    
097    @Override
098    @Nonnull
099    public QueuedSubscriberEventPK getPrimaryKey() {
100        if(_primaryKey == null) {
101            _primaryKey = new QueuedSubscriberEventPK(entityId);
102        }
103        
104        return _primaryKey;
105    }
106    
107    private void clearHashAndString() {
108        _hashCode = null;
109        _stringValue = null;
110    }
111    
112    @Override
113    public int hashCode() {
114        if(_hashCode == null) {
115            int hashCode = 17;
116            
117            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
118            
119            hashCode = 37 * hashCode + ((eventSubscriberPK != null) ? eventSubscriberPK.hashCode() : 0);
120            hashCode = 37 * hashCode + ((eventPK != null) ? eventPK.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                    ", eventSubscriberPK=" + getEventSubscriberPK() +
135                    ", eventPK=" + getEventPK() +
136                    "}";
137        }
138        return _stringValue;
139    }
140    
141    @Override
142    public boolean equals(Object other) {
143        if(this == other)
144            return true;
145        
146        if(!hasIdentity())
147            return false;
148        
149        if(other instanceof  QueuedSubscriberEventValue that) {
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 = 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 that) {
168            boolean objectsEqual = true;
169            
170            
171            if(objectsEqual) {
172                EventSubscriberPK thisEventSubscriberPK = getEventSubscriberPK();
173                EventSubscriberPK thatEventSubscriberPK = that.getEventSubscriberPK();
174                
175                if(thisEventSubscriberPK == null) {
176                    objectsEqual = objectsEqual && (thatEventSubscriberPK == null);
177                } else {
178                    objectsEqual = objectsEqual && thisEventSubscriberPK.equals(thatEventSubscriberPK);
179                }
180            }
181            
182            if(objectsEqual) {
183                EventPK thisEventPK = getEventPK();
184                EventPK thatEventPK = that.getEventPK();
185                
186                if(thisEventPK == null) {
187                    objectsEqual = objectsEqual && (thatEventPK == null);
188                } else {
189                    objectsEqual = objectsEqual && thisEventPK.equals(thatEventPK);
190                }
191            }
192            
193            return objectsEqual;
194        } else {
195            return false;
196        }
197    }
198    
199    @Override
200    public boolean hasBeenModified() {
201        return eventSubscriberPKHasBeenModified || eventPKHasBeenModified;
202    }
203    
204    @Override
205    public void clearHasBeenModified() {
206        eventSubscriberPKHasBeenModified = false;
207        eventPKHasBeenModified = false;
208    }
209    
210    @Nonnull
211    public EventSubscriberPK getEventSubscriberPK() {
212        return eventSubscriberPK;
213    }
214    
215    public void setEventSubscriberPK(@Nonnull 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    @Nonnull
241    public EventPK getEventPK() {
242        return eventPK;
243    }
244    
245    public void setEventPK(@Nonnull EventPK eventPK)
246            throws PersistenceNotNullException {
247        checkForNull(eventPK);
248        
249        boolean update = true;
250        
251        if(this.eventPK != null) {
252            if(this.eventPK.equals(eventPK)) {
253                update = false;
254            }
255        } else if(eventPK == null) {
256            update = false;
257        }
258        
259        if(update) {
260            this.eventPK = eventPK;
261            eventPKHasBeenModified = true;
262            clearHashAndString();
263        }
264    }
265    
266    public boolean getEventPKHasBeenModified() {
267        return eventPKHasBeenModified;
268    }
269    
270}