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 * ClubItemValue.java
021 */
022
023package com.echothree.model.data.club.server.value;
024
025import com.echothree.model.data.club.common.pk.ClubItemPK;
026
027import com.echothree.model.data.club.server.factory.ClubItemFactory;
028
029import com.echothree.model.data.club.common.pk.ClubPK;
030import com.echothree.model.data.club.common.pk.ClubItemTypePK;
031import com.echothree.model.data.item.common.pk.ItemPK;
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
040import javax.annotation.Nonnull;
041import javax.annotation.Nullable;
042
043public class ClubItemValue
044        extends BaseValue<ClubItemPK>
045        implements Cloneable, Serializable {
046    
047    private ClubPK clubPK;
048    private boolean clubPKHasBeenModified = false;
049    private ClubItemTypePK clubItemTypePK;
050    private boolean clubItemTypePKHasBeenModified = false;
051    private ItemPK itemPK;
052    private boolean itemPKHasBeenModified = false;
053    private Long subscriptionTime;
054    private boolean subscriptionTimeHasBeenModified = false;
055    private Long fromTime;
056    private boolean fromTimeHasBeenModified = false;
057    private Long thruTime;
058    private boolean thruTimeHasBeenModified = false;
059    
060    private transient Integer _hashCode = null;
061    private transient String _stringValue = null;
062    
063    private void constructFields(ClubPK clubPK, ClubItemTypePK clubItemTypePK, ItemPK itemPK, Long subscriptionTime, Long fromTime, Long thruTime)
064            throws PersistenceNotNullException {
065        checkForNull(clubPK);
066        this.clubPK = clubPK;
067        checkForNull(clubItemTypePK);
068        this.clubItemTypePK = clubItemTypePK;
069        checkForNull(itemPK);
070        this.itemPK = itemPK;
071        this.subscriptionTime = subscriptionTime;
072        checkForNull(fromTime);
073        this.fromTime = fromTime;
074        checkForNull(thruTime);
075        this.thruTime = thruTime;
076    }
077    
078    /** Creates a new instance of ClubItemValue */
079    public ClubItemValue(ClubItemPK clubItemPK, ClubPK clubPK, ClubItemTypePK clubItemTypePK, ItemPK itemPK, Long subscriptionTime, Long fromTime, Long thruTime)
080            throws PersistenceNotNullException {
081        super(clubItemPK);
082        constructFields(clubPK, clubItemTypePK, itemPK, subscriptionTime, fromTime, thruTime);
083    }
084    
085    /** Creates a new instance of ClubItemValue */
086    public ClubItemValue(ClubPK clubPK, ClubItemTypePK clubItemTypePK, ItemPK itemPK, Long subscriptionTime, Long fromTime, Long thruTime)
087            throws PersistenceNotNullException {
088        super();
089        constructFields(clubPK, clubItemTypePK, itemPK, subscriptionTime, fromTime, thruTime);
090    }
091    
092    @Override
093    @Nonnull
094    public ClubItemFactory getBaseFactoryInstance() {
095        return ClubItemFactory.getInstance();
096    }
097    
098    @Override
099    @Nonnull
100    public ClubItemValue 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 (ClubItemValue)result;
111    }
112    
113    @Override
114    @Nonnull
115    public ClubItemPK getPrimaryKey() {
116        if(_primaryKey == null) {
117            _primaryKey = new ClubItemPK(entityId);
118        }
119        
120        return _primaryKey;
121    }
122    
123    private void clearHashAndString() {
124        _hashCode = null;
125        _stringValue = null;
126    }
127    
128    @Override
129    public int hashCode() {
130        if(_hashCode == null) {
131            int hashCode = 17;
132            
133            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
134            
135            hashCode = 37 * hashCode + ((clubPK != null) ? clubPK.hashCode() : 0);
136            hashCode = 37 * hashCode + ((clubItemTypePK != null) ? clubItemTypePK.hashCode() : 0);
137            hashCode = 37 * hashCode + ((itemPK != null) ? itemPK.hashCode() : 0);
138            hashCode = 37 * hashCode + ((subscriptionTime != null) ? subscriptionTime.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    @Nonnull
150    public String toString() {
151        if(_stringValue == null) {
152            _stringValue = "{" + 
153                    "entityId=" + getEntityId() +
154                    ", clubPK=" + getClubPK() +
155                    ", clubItemTypePK=" + getClubItemTypePK() +
156                    ", itemPK=" + getItemPK() +
157                    ", subscriptionTime=" + getSubscriptionTime() +
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  ClubItemValue 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 ClubItemValue that) {
192            boolean objectsEqual = true;
193            
194            
195            if(objectsEqual) {
196                ClubPK thisClubPK = getClubPK();
197                ClubPK thatClubPK = that.getClubPK();
198                
199                if(thisClubPK == null) {
200                    objectsEqual = objectsEqual && (thatClubPK == null);
201                } else {
202                    objectsEqual = objectsEqual && thisClubPK.equals(thatClubPK);
203                }
204            }
205            
206            if(objectsEqual) {
207                ClubItemTypePK thisClubItemTypePK = getClubItemTypePK();
208                ClubItemTypePK thatClubItemTypePK = that.getClubItemTypePK();
209                
210                if(thisClubItemTypePK == null) {
211                    objectsEqual = objectsEqual && (thatClubItemTypePK == null);
212                } else {
213                    objectsEqual = objectsEqual && thisClubItemTypePK.equals(thatClubItemTypePK);
214                }
215            }
216            
217            if(objectsEqual) {
218                ItemPK thisItemPK = getItemPK();
219                ItemPK thatItemPK = that.getItemPK();
220                
221                if(thisItemPK == null) {
222                    objectsEqual = objectsEqual && (thatItemPK == null);
223                } else {
224                    objectsEqual = objectsEqual && thisItemPK.equals(thatItemPK);
225                }
226            }
227            
228            if(objectsEqual) {
229                Long thisSubscriptionTime = getSubscriptionTime();
230                Long thatSubscriptionTime = that.getSubscriptionTime();
231                
232                if(thisSubscriptionTime == null) {
233                    objectsEqual = objectsEqual && (thatSubscriptionTime == null);
234                } else {
235                    objectsEqual = objectsEqual && thisSubscriptionTime.equals(thatSubscriptionTime);
236                }
237            }
238            
239            if(objectsEqual) {
240                Long thisFromTime = getFromTime();
241                Long thatFromTime = that.getFromTime();
242                
243                if(thisFromTime == null) {
244                    objectsEqual = objectsEqual && (thatFromTime == null);
245                } else {
246                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
247                }
248            }
249            
250            if(objectsEqual) {
251                Long thisThruTime = getThruTime();
252                Long thatThruTime = that.getThruTime();
253                
254                if(thisThruTime == null) {
255                    objectsEqual = objectsEqual && (thatThruTime == null);
256                } else {
257                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
258                }
259            }
260            
261            return objectsEqual;
262        } else {
263            return false;
264        }
265    }
266    
267    @Override
268    public boolean hasBeenModified() {
269        return clubPKHasBeenModified || clubItemTypePKHasBeenModified || itemPKHasBeenModified || subscriptionTimeHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
270    }
271    
272    @Override
273    public void clearHasBeenModified() {
274        clubPKHasBeenModified = false;
275        clubItemTypePKHasBeenModified = false;
276        itemPKHasBeenModified = false;
277        subscriptionTimeHasBeenModified = false;
278        fromTimeHasBeenModified = false;
279        thruTimeHasBeenModified = false;
280    }
281    
282    @Nonnull
283    public ClubPK getClubPK() {
284        return clubPK;
285    }
286    
287    public void setClubPK(@Nonnull ClubPK clubPK)
288            throws PersistenceNotNullException {
289        checkForNull(clubPK);
290        
291        boolean update = true;
292        
293        if(this.clubPK != null) {
294            if(this.clubPK.equals(clubPK)) {
295                update = false;
296            }
297        } else if(clubPK == null) {
298            update = false;
299        }
300        
301        if(update) {
302            this.clubPK = clubPK;
303            clubPKHasBeenModified = true;
304            clearHashAndString();
305        }
306    }
307    
308    public boolean getClubPKHasBeenModified() {
309        return clubPKHasBeenModified;
310    }
311    
312    @Nonnull
313    public ClubItemTypePK getClubItemTypePK() {
314        return clubItemTypePK;
315    }
316    
317    public void setClubItemTypePK(@Nonnull ClubItemTypePK clubItemTypePK)
318            throws PersistenceNotNullException {
319        checkForNull(clubItemTypePK);
320        
321        boolean update = true;
322        
323        if(this.clubItemTypePK != null) {
324            if(this.clubItemTypePK.equals(clubItemTypePK)) {
325                update = false;
326            }
327        } else if(clubItemTypePK == null) {
328            update = false;
329        }
330        
331        if(update) {
332            this.clubItemTypePK = clubItemTypePK;
333            clubItemTypePKHasBeenModified = true;
334            clearHashAndString();
335        }
336    }
337    
338    public boolean getClubItemTypePKHasBeenModified() {
339        return clubItemTypePKHasBeenModified;
340    }
341    
342    @Nonnull
343    public ItemPK getItemPK() {
344        return itemPK;
345    }
346    
347    public void setItemPK(@Nonnull ItemPK itemPK)
348            throws PersistenceNotNullException {
349        checkForNull(itemPK);
350        
351        boolean update = true;
352        
353        if(this.itemPK != null) {
354            if(this.itemPK.equals(itemPK)) {
355                update = false;
356            }
357        } else if(itemPK == null) {
358            update = false;
359        }
360        
361        if(update) {
362            this.itemPK = itemPK;
363            itemPKHasBeenModified = true;
364            clearHashAndString();
365        }
366    }
367    
368    public boolean getItemPKHasBeenModified() {
369        return itemPKHasBeenModified;
370    }
371    
372    @Nullable
373    public Long getSubscriptionTime() {
374        return subscriptionTime;
375    }
376    
377    public void setSubscriptionTime(@Nullable Long subscriptionTime) {
378        boolean update = true;
379        
380        if(this.subscriptionTime != null) {
381            if(this.subscriptionTime.equals(subscriptionTime)) {
382                update = false;
383            }
384        } else if(subscriptionTime == null) {
385            update = false;
386        }
387        
388        if(update) {
389            this.subscriptionTime = subscriptionTime;
390            subscriptionTimeHasBeenModified = true;
391            clearHashAndString();
392        }
393    }
394    
395    public boolean getSubscriptionTimeHasBeenModified() {
396        return subscriptionTimeHasBeenModified;
397    }
398    
399    @Nonnull
400    public Long getFromTime() {
401        return fromTime;
402    }
403    
404    public void setFromTime(@Nonnull Long fromTime)
405            throws PersistenceNotNullException {
406        checkForNull(fromTime);
407        
408        boolean update = true;
409        
410        if(this.fromTime != null) {
411            if(this.fromTime.equals(fromTime)) {
412                update = false;
413            }
414        } else if(fromTime == null) {
415            update = false;
416        }
417        
418        if(update) {
419            this.fromTime = fromTime;
420            fromTimeHasBeenModified = true;
421            clearHashAndString();
422        }
423    }
424    
425    public boolean getFromTimeHasBeenModified() {
426        return fromTimeHasBeenModified;
427    }
428    
429    @Nonnull
430    public Long getThruTime() {
431        return thruTime;
432    }
433    
434    public void setThruTime(@Nonnull Long thruTime)
435            throws PersistenceNotNullException {
436        checkForNull(thruTime);
437        
438        boolean update = true;
439        
440        if(this.thruTime != null) {
441            if(this.thruTime.equals(thruTime)) {
442                update = false;
443            }
444        } else if(thruTime == null) {
445            update = false;
446        }
447        
448        if(update) {
449            this.thruTime = thruTime;
450            thruTimeHasBeenModified = true;
451            clearHashAndString();
452        }
453    }
454    
455    public boolean getThruTimeHasBeenModified() {
456        return thruTimeHasBeenModified;
457    }
458    
459}