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 * PartyRelationshipValue.java
021 */
022
023package com.echothree.model.data.party.server.value;
024
025import com.echothree.model.data.party.common.pk.PartyRelationshipPK;
026
027import com.echothree.model.data.party.server.factory.PartyRelationshipFactory;
028
029import com.echothree.model.data.party.common.pk.PartyRelationshipTypePK;
030import com.echothree.model.data.party.common.pk.PartyPK;
031import com.echothree.model.data.party.common.pk.RoleTypePK;
032
033import com.echothree.util.common.exception.PersistenceCloneException;
034import com.echothree.util.common.exception.PersistenceNotNullException;
035
036import com.echothree.util.server.persistence.BaseValue;
037
038import java.io.Serializable;
039
040public class PartyRelationshipValue
041        extends BaseValue<PartyRelationshipPK>
042        implements Cloneable, Serializable {
043    
044    private PartyRelationshipTypePK partyRelationshipTypePK;
045    private boolean partyRelationshipTypePKHasBeenModified = false;
046    private PartyPK fromPartyPK;
047    private boolean fromPartyPKHasBeenModified = false;
048    private RoleTypePK fromRoleTypePK;
049    private boolean fromRoleTypePKHasBeenModified = false;
050    private PartyPK toPartyPK;
051    private boolean toPartyPKHasBeenModified = false;
052    private RoleTypePK toRoleTypePK;
053    private boolean toRoleTypePKHasBeenModified = false;
054    private Long fromTime;
055    private boolean fromTimeHasBeenModified = false;
056    private Long thruTime;
057    private boolean thruTimeHasBeenModified = false;
058    
059    private transient Integer _hashCode = null;
060    private transient String _stringValue = null;
061    
062    private void constructFields(PartyRelationshipTypePK partyRelationshipTypePK, PartyPK fromPartyPK, RoleTypePK fromRoleTypePK, PartyPK toPartyPK, RoleTypePK toRoleTypePK, Long fromTime, Long thruTime)
063            throws PersistenceNotNullException {
064        checkForNull(partyRelationshipTypePK);
065        this.partyRelationshipTypePK = partyRelationshipTypePK;
066        checkForNull(fromPartyPK);
067        this.fromPartyPK = fromPartyPK;
068        checkForNull(fromRoleTypePK);
069        this.fromRoleTypePK = fromRoleTypePK;
070        checkForNull(toPartyPK);
071        this.toPartyPK = toPartyPK;
072        checkForNull(toRoleTypePK);
073        this.toRoleTypePK = toRoleTypePK;
074        checkForNull(fromTime);
075        this.fromTime = fromTime;
076        checkForNull(thruTime);
077        this.thruTime = thruTime;
078    }
079    
080    /** Creates a new instance of PartyRelationshipValue */
081    public PartyRelationshipValue(PartyRelationshipPK partyRelationshipPK, PartyRelationshipTypePK partyRelationshipTypePK, PartyPK fromPartyPK, RoleTypePK fromRoleTypePK, PartyPK toPartyPK, RoleTypePK toRoleTypePK, Long fromTime, Long thruTime)
082            throws PersistenceNotNullException {
083        super(partyRelationshipPK);
084        constructFields(partyRelationshipTypePK, fromPartyPK, fromRoleTypePK, toPartyPK, toRoleTypePK, fromTime, thruTime);
085    }
086    
087    /** Creates a new instance of PartyRelationshipValue */
088    public PartyRelationshipValue(PartyRelationshipTypePK partyRelationshipTypePK, PartyPK fromPartyPK, RoleTypePK fromRoleTypePK, PartyPK toPartyPK, RoleTypePK toRoleTypePK, Long fromTime, Long thruTime)
089            throws PersistenceNotNullException {
090        super();
091        constructFields(partyRelationshipTypePK, fromPartyPK, fromRoleTypePK, toPartyPK, toRoleTypePK, fromTime, thruTime);
092    }
093    
094   @Override
095   public PartyRelationshipFactory getBaseFactoryInstance() {
096        return PartyRelationshipFactory.getInstance();
097    }
098    
099    @Override
100    public PartyRelationshipValue clone() {
101        Object result;
102        
103        try {
104            result = super.clone();
105        } catch (CloneNotSupportedException cnse) {
106            // This shouldn't happen, fail when it does.
107            throw new PersistenceCloneException(cnse);
108        }
109        
110        return (PartyRelationshipValue)result;
111    }
112    
113   @Override
114    public PartyRelationshipPK getPrimaryKey() {
115        if(_primaryKey == null) {
116            _primaryKey = new PartyRelationshipPK(entityId);
117        }
118        
119        return _primaryKey;
120    }
121    
122    private void clearHashAndString() {
123        _hashCode = null;
124        _stringValue = null;
125    }
126    
127    @Override
128    public int hashCode() {
129        if(_hashCode == null) {
130            int hashCode = 17;
131            
132            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
133            
134            hashCode = 37 * hashCode + ((partyRelationshipTypePK != null) ? partyRelationshipTypePK.hashCode() : 0);
135            hashCode = 37 * hashCode + ((fromPartyPK != null) ? fromPartyPK.hashCode() : 0);
136            hashCode = 37 * hashCode + ((fromRoleTypePK != null) ? fromRoleTypePK.hashCode() : 0);
137            hashCode = 37 * hashCode + ((toPartyPK != null) ? toPartyPK.hashCode() : 0);
138            hashCode = 37 * hashCode + ((toRoleTypePK != null) ? toRoleTypePK.hashCode() : 0);
139            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
140            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
141            
142            _hashCode = hashCode;
143        }
144        
145        return _hashCode;
146    }
147    
148    @Override
149    public String toString() {
150        if(_stringValue == null) {
151            _stringValue = "{" + 
152                    "entityId=" + getEntityId() +
153                    ", partyRelationshipTypePK=" + getPartyRelationshipTypePK() +
154                    ", fromPartyPK=" + getFromPartyPK() +
155                    ", fromRoleTypePK=" + getFromRoleTypePK() +
156                    ", toPartyPK=" + getToPartyPK() +
157                    ", toRoleTypePK=" + getToRoleTypePK() +
158                    ", fromTime=" + getFromTime() +
159                    ", thruTime=" + getThruTime() +
160                    "}";
161        }
162        return _stringValue;
163    }
164    
165    @Override
166    public boolean equals(Object other) {
167        if(this == other)
168            return true;
169        
170        if(!hasIdentity())
171            return false;
172        
173        if(other instanceof  PartyRelationshipValue that) {
174            if(!that.hasIdentity())
175                return false;
176            
177            Long thisEntityId = getEntityId();
178            Long thatEntityId = that.getEntityId();
179            
180            boolean objectsEqual = thisEntityId.equals(thatEntityId);
181            if(objectsEqual)
182                objectsEqual = isIdentical(that);
183            
184            return objectsEqual;
185        } else {
186            return false;
187        }
188    }
189    
190    public boolean isIdentical(Object other) {
191        if(other instanceof PartyRelationshipValue that) {
192            boolean objectsEqual = true;
193            
194            
195            if(objectsEqual) {
196                PartyRelationshipTypePK thisPartyRelationshipTypePK = getPartyRelationshipTypePK();
197                PartyRelationshipTypePK thatPartyRelationshipTypePK = that.getPartyRelationshipTypePK();
198                
199                if(thisPartyRelationshipTypePK == null) {
200                    objectsEqual = objectsEqual && (thatPartyRelationshipTypePK == null);
201                } else {
202                    objectsEqual = objectsEqual && thisPartyRelationshipTypePK.equals(thatPartyRelationshipTypePK);
203                }
204            }
205            
206            if(objectsEqual) {
207                PartyPK thisFromPartyPK = getFromPartyPK();
208                PartyPK thatFromPartyPK = that.getFromPartyPK();
209                
210                if(thisFromPartyPK == null) {
211                    objectsEqual = objectsEqual && (thatFromPartyPK == null);
212                } else {
213                    objectsEqual = objectsEqual && thisFromPartyPK.equals(thatFromPartyPK);
214                }
215            }
216            
217            if(objectsEqual) {
218                RoleTypePK thisFromRoleTypePK = getFromRoleTypePK();
219                RoleTypePK thatFromRoleTypePK = that.getFromRoleTypePK();
220                
221                if(thisFromRoleTypePK == null) {
222                    objectsEqual = objectsEqual && (thatFromRoleTypePK == null);
223                } else {
224                    objectsEqual = objectsEqual && thisFromRoleTypePK.equals(thatFromRoleTypePK);
225                }
226            }
227            
228            if(objectsEqual) {
229                PartyPK thisToPartyPK = getToPartyPK();
230                PartyPK thatToPartyPK = that.getToPartyPK();
231                
232                if(thisToPartyPK == null) {
233                    objectsEqual = objectsEqual && (thatToPartyPK == null);
234                } else {
235                    objectsEqual = objectsEqual && thisToPartyPK.equals(thatToPartyPK);
236                }
237            }
238            
239            if(objectsEqual) {
240                RoleTypePK thisToRoleTypePK = getToRoleTypePK();
241                RoleTypePK thatToRoleTypePK = that.getToRoleTypePK();
242                
243                if(thisToRoleTypePK == null) {
244                    objectsEqual = objectsEqual && (thatToRoleTypePK == null);
245                } else {
246                    objectsEqual = objectsEqual && thisToRoleTypePK.equals(thatToRoleTypePK);
247                }
248            }
249            
250            if(objectsEqual) {
251                Long thisFromTime = getFromTime();
252                Long thatFromTime = that.getFromTime();
253                
254                if(thisFromTime == null) {
255                    objectsEqual = objectsEqual && (thatFromTime == null);
256                } else {
257                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
258                }
259            }
260            
261            if(objectsEqual) {
262                Long thisThruTime = getThruTime();
263                Long thatThruTime = that.getThruTime();
264                
265                if(thisThruTime == null) {
266                    objectsEqual = objectsEqual && (thatThruTime == null);
267                } else {
268                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
269                }
270            }
271            
272            return objectsEqual;
273        } else {
274            return false;
275        }
276    }
277    
278    @Override
279    public boolean hasBeenModified() {
280        return partyRelationshipTypePKHasBeenModified || fromPartyPKHasBeenModified || fromRoleTypePKHasBeenModified || toPartyPKHasBeenModified || toRoleTypePKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
281    }
282    
283    @Override
284    public void clearHasBeenModified() {
285        partyRelationshipTypePKHasBeenModified = false;
286        fromPartyPKHasBeenModified = false;
287        fromRoleTypePKHasBeenModified = false;
288        toPartyPKHasBeenModified = false;
289        toRoleTypePKHasBeenModified = false;
290        fromTimeHasBeenModified = false;
291        thruTimeHasBeenModified = false;
292    }
293    
294    public PartyRelationshipTypePK getPartyRelationshipTypePK() {
295        return partyRelationshipTypePK;
296    }
297    
298    public void setPartyRelationshipTypePK(PartyRelationshipTypePK partyRelationshipTypePK)
299            throws PersistenceNotNullException {
300        checkForNull(partyRelationshipTypePK);
301        
302        boolean update = true;
303        
304        if(this.partyRelationshipTypePK != null) {
305            if(this.partyRelationshipTypePK.equals(partyRelationshipTypePK)) {
306                update = false;
307            }
308        } else if(partyRelationshipTypePK == null) {
309            update = false;
310        }
311        
312        if(update) {
313            this.partyRelationshipTypePK = partyRelationshipTypePK;
314            partyRelationshipTypePKHasBeenModified = true;
315            clearHashAndString();
316        }
317    }
318    
319    public boolean getPartyRelationshipTypePKHasBeenModified() {
320        return partyRelationshipTypePKHasBeenModified;
321    }
322    
323    public PartyPK getFromPartyPK() {
324        return fromPartyPK;
325    }
326    
327    public void setFromPartyPK(PartyPK fromPartyPK)
328            throws PersistenceNotNullException {
329        checkForNull(fromPartyPK);
330        
331        boolean update = true;
332        
333        if(this.fromPartyPK != null) {
334            if(this.fromPartyPK.equals(fromPartyPK)) {
335                update = false;
336            }
337        } else if(fromPartyPK == null) {
338            update = false;
339        }
340        
341        if(update) {
342            this.fromPartyPK = fromPartyPK;
343            fromPartyPKHasBeenModified = true;
344            clearHashAndString();
345        }
346    }
347    
348    public boolean getFromPartyPKHasBeenModified() {
349        return fromPartyPKHasBeenModified;
350    }
351    
352    public RoleTypePK getFromRoleTypePK() {
353        return fromRoleTypePK;
354    }
355    
356    public void setFromRoleTypePK(RoleTypePK fromRoleTypePK)
357            throws PersistenceNotNullException {
358        checkForNull(fromRoleTypePK);
359        
360        boolean update = true;
361        
362        if(this.fromRoleTypePK != null) {
363            if(this.fromRoleTypePK.equals(fromRoleTypePK)) {
364                update = false;
365            }
366        } else if(fromRoleTypePK == null) {
367            update = false;
368        }
369        
370        if(update) {
371            this.fromRoleTypePK = fromRoleTypePK;
372            fromRoleTypePKHasBeenModified = true;
373            clearHashAndString();
374        }
375    }
376    
377    public boolean getFromRoleTypePKHasBeenModified() {
378        return fromRoleTypePKHasBeenModified;
379    }
380    
381    public PartyPK getToPartyPK() {
382        return toPartyPK;
383    }
384    
385    public void setToPartyPK(PartyPK toPartyPK)
386            throws PersistenceNotNullException {
387        checkForNull(toPartyPK);
388        
389        boolean update = true;
390        
391        if(this.toPartyPK != null) {
392            if(this.toPartyPK.equals(toPartyPK)) {
393                update = false;
394            }
395        } else if(toPartyPK == null) {
396            update = false;
397        }
398        
399        if(update) {
400            this.toPartyPK = toPartyPK;
401            toPartyPKHasBeenModified = true;
402            clearHashAndString();
403        }
404    }
405    
406    public boolean getToPartyPKHasBeenModified() {
407        return toPartyPKHasBeenModified;
408    }
409    
410    public RoleTypePK getToRoleTypePK() {
411        return toRoleTypePK;
412    }
413    
414    public void setToRoleTypePK(RoleTypePK toRoleTypePK)
415            throws PersistenceNotNullException {
416        checkForNull(toRoleTypePK);
417        
418        boolean update = true;
419        
420        if(this.toRoleTypePK != null) {
421            if(this.toRoleTypePK.equals(toRoleTypePK)) {
422                update = false;
423            }
424        } else if(toRoleTypePK == null) {
425            update = false;
426        }
427        
428        if(update) {
429            this.toRoleTypePK = toRoleTypePK;
430            toRoleTypePKHasBeenModified = true;
431            clearHashAndString();
432        }
433    }
434    
435    public boolean getToRoleTypePKHasBeenModified() {
436        return toRoleTypePKHasBeenModified;
437    }
438    
439    public Long getFromTime() {
440        return fromTime;
441    }
442    
443    public void setFromTime(Long fromTime)
444            throws PersistenceNotNullException {
445        checkForNull(fromTime);
446        
447        boolean update = true;
448        
449        if(this.fromTime != null) {
450            if(this.fromTime.equals(fromTime)) {
451                update = false;
452            }
453        } else if(fromTime == null) {
454            update = false;
455        }
456        
457        if(update) {
458            this.fromTime = fromTime;
459            fromTimeHasBeenModified = true;
460            clearHashAndString();
461        }
462    }
463    
464    public boolean getFromTimeHasBeenModified() {
465        return fromTimeHasBeenModified;
466    }
467    
468    public Long getThruTime() {
469        return thruTime;
470    }
471    
472    public void setThruTime(Long thruTime)
473            throws PersistenceNotNullException {
474        checkForNull(thruTime);
475        
476        boolean update = true;
477        
478        if(this.thruTime != null) {
479            if(this.thruTime.equals(thruTime)) {
480                update = false;
481            }
482        } else if(thruTime == null) {
483            update = false;
484        }
485        
486        if(update) {
487            this.thruTime = thruTime;
488            thruTimeHasBeenModified = true;
489            clearHashAndString();
490        }
491    }
492    
493    public boolean getThruTimeHasBeenModified() {
494        return thruTimeHasBeenModified;
495    }
496    
497}