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 * 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            _stringValue = "{" + 
126                    "entityId=" + getEntityId() +
127                    ", eventSubscriberPK=" + getEventSubscriberPK() +
128                    ", eventPK=" + getEventPK() +
129                    "}";
130        }
131        return _stringValue;
132    }
133    
134    @Override
135    public boolean equals(Object other) {
136        if(this == other)
137            return true;
138        
139        if(!hasIdentity())
140            return false;
141        
142        if(other instanceof  QueuedSubscriberEventValue that) {
143            if(!that.hasIdentity())
144                return false;
145            
146            Long thisEntityId = getEntityId();
147            Long thatEntityId = that.getEntityId();
148            
149            boolean objectsEqual = thisEntityId.equals(thatEntityId);
150            if(objectsEqual)
151                objectsEqual = isIdentical(that);
152            
153            return objectsEqual;
154        } else {
155            return false;
156        }
157    }
158    
159    public boolean isIdentical(Object other) {
160        if(other instanceof QueuedSubscriberEventValue that) {
161            boolean objectsEqual = true;
162            
163            
164            if(objectsEqual) {
165                EventSubscriberPK thisEventSubscriberPK = getEventSubscriberPK();
166                EventSubscriberPK thatEventSubscriberPK = that.getEventSubscriberPK();
167                
168                if(thisEventSubscriberPK == null) {
169                    objectsEqual = objectsEqual && (thatEventSubscriberPK == null);
170                } else {
171                    objectsEqual = objectsEqual && thisEventSubscriberPK.equals(thatEventSubscriberPK);
172                }
173            }
174            
175            if(objectsEqual) {
176                EventPK thisEventPK = getEventPK();
177                EventPK thatEventPK = that.getEventPK();
178                
179                if(thisEventPK == null) {
180                    objectsEqual = objectsEqual && (thatEventPK == null);
181                } else {
182                    objectsEqual = objectsEqual && thisEventPK.equals(thatEventPK);
183                }
184            }
185            
186            return objectsEqual;
187        } else {
188            return false;
189        }
190    }
191    
192    @Override
193    public boolean hasBeenModified() {
194        return eventSubscriberPKHasBeenModified || eventPKHasBeenModified;
195    }
196    
197    @Override
198    public void clearHasBeenModified() {
199        eventSubscriberPKHasBeenModified = false;
200        eventPKHasBeenModified = false;
201    }
202    
203    public EventSubscriberPK getEventSubscriberPK() {
204        return eventSubscriberPK;
205    }
206    
207    public void setEventSubscriberPK(EventSubscriberPK eventSubscriberPK)
208            throws PersistenceNotNullException {
209        checkForNull(eventSubscriberPK);
210        
211        boolean update = true;
212        
213        if(this.eventSubscriberPK != null) {
214            if(this.eventSubscriberPK.equals(eventSubscriberPK)) {
215                update = false;
216            }
217        } else if(eventSubscriberPK == null) {
218            update = false;
219        }
220        
221        if(update) {
222            this.eventSubscriberPK = eventSubscriberPK;
223            eventSubscriberPKHasBeenModified = true;
224            clearHashAndString();
225        }
226    }
227    
228    public boolean getEventSubscriberPKHasBeenModified() {
229        return eventSubscriberPKHasBeenModified;
230    }
231    
232    public EventPK getEventPK() {
233        return eventPK;
234    }
235    
236    public void setEventPK(EventPK eventPK)
237            throws PersistenceNotNullException {
238        checkForNull(eventPK);
239        
240        boolean update = true;
241        
242        if(this.eventPK != null) {
243            if(this.eventPK.equals(eventPK)) {
244                update = false;
245            }
246        } else if(eventPK == null) {
247            update = false;
248        }
249        
250        if(update) {
251            this.eventPK = eventPK;
252            eventPKHasBeenModified = true;
253            clearHashAndString();
254        }
255    }
256    
257    public boolean getEventPKHasBeenModified() {
258        return eventPKHasBeenModified;
259    }
260    
261}