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 * PartyInventoryLevelValue.java
021 */
022
023package com.echothree.model.data.inventory.server.value;
024
025import com.echothree.model.data.inventory.common.pk.PartyInventoryLevelPK;
026
027import com.echothree.model.data.inventory.server.factory.PartyInventoryLevelFactory;
028
029import com.echothree.model.data.party.common.pk.PartyPK;
030import com.echothree.model.data.item.common.pk.ItemPK;
031import com.echothree.model.data.inventory.common.pk.InventoryConditionPK;
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 PartyInventoryLevelValue
044        extends BaseValue<PartyInventoryLevelPK>
045        implements Cloneable, Serializable {
046    
047    private PartyPK partyPK;
048    private boolean partyPKHasBeenModified = false;
049    private ItemPK itemPK;
050    private boolean itemPKHasBeenModified = false;
051    private InventoryConditionPK inventoryConditionPK;
052    private boolean inventoryConditionPKHasBeenModified = false;
053    private Long minimumInventory;
054    private boolean minimumInventoryHasBeenModified = false;
055    private Long maximumInventory;
056    private boolean maximumInventoryHasBeenModified = false;
057    private Long reorderQuantity;
058    private boolean reorderQuantityHasBeenModified = false;
059    private Long fromTime;
060    private boolean fromTimeHasBeenModified = false;
061    private Long thruTime;
062    private boolean thruTimeHasBeenModified = false;
063    
064    private transient Integer _hashCode = null;
065    private transient String _stringValue = null;
066    
067    private void constructFields(PartyPK partyPK, ItemPK itemPK, InventoryConditionPK inventoryConditionPK, Long minimumInventory, Long maximumInventory, Long reorderQuantity, Long fromTime, Long thruTime)
068            throws PersistenceNotNullException {
069        checkForNull(partyPK);
070        this.partyPK = partyPK;
071        checkForNull(itemPK);
072        this.itemPK = itemPK;
073        checkForNull(inventoryConditionPK);
074        this.inventoryConditionPK = inventoryConditionPK;
075        this.minimumInventory = minimumInventory;
076        this.maximumInventory = maximumInventory;
077        this.reorderQuantity = reorderQuantity;
078        checkForNull(fromTime);
079        this.fromTime = fromTime;
080        checkForNull(thruTime);
081        this.thruTime = thruTime;
082    }
083    
084    /** Creates a new instance of PartyInventoryLevelValue */
085    public PartyInventoryLevelValue(PartyInventoryLevelPK partyInventoryLevelPK, PartyPK partyPK, ItemPK itemPK, InventoryConditionPK inventoryConditionPK, Long minimumInventory, Long maximumInventory, Long reorderQuantity, Long fromTime, Long thruTime)
086            throws PersistenceNotNullException {
087        super(partyInventoryLevelPK);
088        constructFields(partyPK, itemPK, inventoryConditionPK, minimumInventory, maximumInventory, reorderQuantity, fromTime, thruTime);
089    }
090    
091    /** Creates a new instance of PartyInventoryLevelValue */
092    public PartyInventoryLevelValue(PartyPK partyPK, ItemPK itemPK, InventoryConditionPK inventoryConditionPK, Long minimumInventory, Long maximumInventory, Long reorderQuantity, Long fromTime, Long thruTime)
093            throws PersistenceNotNullException {
094        super();
095        constructFields(partyPK, itemPK, inventoryConditionPK, minimumInventory, maximumInventory, reorderQuantity, fromTime, thruTime);
096    }
097    
098    @Override
099    @Nonnull
100    public PartyInventoryLevelFactory getBaseFactoryInstance() {
101        return PartyInventoryLevelFactory.getInstance();
102    }
103    
104    @Override
105    @Nonnull
106    public PartyInventoryLevelValue clone() {
107        Object result;
108        
109        try {
110            result = super.clone();
111        } catch (CloneNotSupportedException cnse) {
112            // This shouldn't happen, fail when it does.
113            throw new PersistenceCloneException(cnse);
114        }
115        
116        return (PartyInventoryLevelValue)result;
117    }
118    
119    @Override
120    @Nonnull
121    public PartyInventoryLevelPK getPrimaryKey() {
122        if(_primaryKey == null) {
123            _primaryKey = new PartyInventoryLevelPK(entityId);
124        }
125        
126        return _primaryKey;
127    }
128    
129    private void clearHashAndString() {
130        _hashCode = null;
131        _stringValue = null;
132    }
133    
134    @Override
135    public int hashCode() {
136        if(_hashCode == null) {
137            int hashCode = 17;
138            
139            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
140            
141            hashCode = 37 * hashCode + ((partyPK != null) ? partyPK.hashCode() : 0);
142            hashCode = 37 * hashCode + ((itemPK != null) ? itemPK.hashCode() : 0);
143            hashCode = 37 * hashCode + ((inventoryConditionPK != null) ? inventoryConditionPK.hashCode() : 0);
144            hashCode = 37 * hashCode + ((minimumInventory != null) ? minimumInventory.hashCode() : 0);
145            hashCode = 37 * hashCode + ((maximumInventory != null) ? maximumInventory.hashCode() : 0);
146            hashCode = 37 * hashCode + ((reorderQuantity != null) ? reorderQuantity.hashCode() : 0);
147            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
148            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
149            
150            _hashCode = hashCode;
151        }
152        
153        return _hashCode;
154    }
155    
156    @Override
157    @Nonnull
158    public String toString() {
159        if(_stringValue == null) {
160            _stringValue = "{" + 
161                    "entityId=" + getEntityId() +
162                    ", partyPK=" + getPartyPK() +
163                    ", itemPK=" + getItemPK() +
164                    ", inventoryConditionPK=" + getInventoryConditionPK() +
165                    ", minimumInventory=" + getMinimumInventory() +
166                    ", maximumInventory=" + getMaximumInventory() +
167                    ", reorderQuantity=" + getReorderQuantity() +
168                    ", fromTime=" + getFromTime() +
169                    ", thruTime=" + getThruTime() +
170                    "}";
171        }
172        return _stringValue;
173    }
174    
175    @Override
176    public boolean equals(Object other) {
177        if(this == other)
178            return true;
179        
180        if(!hasIdentity())
181            return false;
182        
183        if(other instanceof  PartyInventoryLevelValue that) {
184            if(!that.hasIdentity())
185                return false;
186            
187            Long thisEntityId = getEntityId();
188            Long thatEntityId = that.getEntityId();
189            
190            boolean objectsEqual = thisEntityId.equals(thatEntityId);
191            if(objectsEqual)
192                objectsEqual = isIdentical(that);
193            
194            return objectsEqual;
195        } else {
196            return false;
197        }
198    }
199    
200    public boolean isIdentical(Object other) {
201        if(other instanceof PartyInventoryLevelValue that) {
202            boolean objectsEqual = true;
203            
204            
205            if(objectsEqual) {
206                PartyPK thisPartyPK = getPartyPK();
207                PartyPK thatPartyPK = that.getPartyPK();
208                
209                if(thisPartyPK == null) {
210                    objectsEqual = objectsEqual && (thatPartyPK == null);
211                } else {
212                    objectsEqual = objectsEqual && thisPartyPK.equals(thatPartyPK);
213                }
214            }
215            
216            if(objectsEqual) {
217                ItemPK thisItemPK = getItemPK();
218                ItemPK thatItemPK = that.getItemPK();
219                
220                if(thisItemPK == null) {
221                    objectsEqual = objectsEqual && (thatItemPK == null);
222                } else {
223                    objectsEqual = objectsEqual && thisItemPK.equals(thatItemPK);
224                }
225            }
226            
227            if(objectsEqual) {
228                InventoryConditionPK thisInventoryConditionPK = getInventoryConditionPK();
229                InventoryConditionPK thatInventoryConditionPK = that.getInventoryConditionPK();
230                
231                if(thisInventoryConditionPK == null) {
232                    objectsEqual = objectsEqual && (thatInventoryConditionPK == null);
233                } else {
234                    objectsEqual = objectsEqual && thisInventoryConditionPK.equals(thatInventoryConditionPK);
235                }
236            }
237            
238            if(objectsEqual) {
239                Long thisMinimumInventory = getMinimumInventory();
240                Long thatMinimumInventory = that.getMinimumInventory();
241                
242                if(thisMinimumInventory == null) {
243                    objectsEqual = objectsEqual && (thatMinimumInventory == null);
244                } else {
245                    objectsEqual = objectsEqual && thisMinimumInventory.equals(thatMinimumInventory);
246                }
247            }
248            
249            if(objectsEqual) {
250                Long thisMaximumInventory = getMaximumInventory();
251                Long thatMaximumInventory = that.getMaximumInventory();
252                
253                if(thisMaximumInventory == null) {
254                    objectsEqual = objectsEqual && (thatMaximumInventory == null);
255                } else {
256                    objectsEqual = objectsEqual && thisMaximumInventory.equals(thatMaximumInventory);
257                }
258            }
259            
260            if(objectsEqual) {
261                Long thisReorderQuantity = getReorderQuantity();
262                Long thatReorderQuantity = that.getReorderQuantity();
263                
264                if(thisReorderQuantity == null) {
265                    objectsEqual = objectsEqual && (thatReorderQuantity == null);
266                } else {
267                    objectsEqual = objectsEqual && thisReorderQuantity.equals(thatReorderQuantity);
268                }
269            }
270            
271            if(objectsEqual) {
272                Long thisFromTime = getFromTime();
273                Long thatFromTime = that.getFromTime();
274                
275                if(thisFromTime == null) {
276                    objectsEqual = objectsEqual && (thatFromTime == null);
277                } else {
278                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
279                }
280            }
281            
282            if(objectsEqual) {
283                Long thisThruTime = getThruTime();
284                Long thatThruTime = that.getThruTime();
285                
286                if(thisThruTime == null) {
287                    objectsEqual = objectsEqual && (thatThruTime == null);
288                } else {
289                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
290                }
291            }
292            
293            return objectsEqual;
294        } else {
295            return false;
296        }
297    }
298    
299    @Override
300    public boolean hasBeenModified() {
301        return partyPKHasBeenModified || itemPKHasBeenModified || inventoryConditionPKHasBeenModified || minimumInventoryHasBeenModified || maximumInventoryHasBeenModified || reorderQuantityHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
302    }
303    
304    @Override
305    public void clearHasBeenModified() {
306        partyPKHasBeenModified = false;
307        itemPKHasBeenModified = false;
308        inventoryConditionPKHasBeenModified = false;
309        minimumInventoryHasBeenModified = false;
310        maximumInventoryHasBeenModified = false;
311        reorderQuantityHasBeenModified = false;
312        fromTimeHasBeenModified = false;
313        thruTimeHasBeenModified = false;
314    }
315    
316    @Nonnull
317    public PartyPK getPartyPK() {
318        return partyPK;
319    }
320    
321    public void setPartyPK(@Nonnull PartyPK partyPK)
322            throws PersistenceNotNullException {
323        checkForNull(partyPK);
324        
325        boolean update = true;
326        
327        if(this.partyPK != null) {
328            if(this.partyPK.equals(partyPK)) {
329                update = false;
330            }
331        } else if(partyPK == null) {
332            update = false;
333        }
334        
335        if(update) {
336            this.partyPK = partyPK;
337            partyPKHasBeenModified = true;
338            clearHashAndString();
339        }
340    }
341    
342    public boolean getPartyPKHasBeenModified() {
343        return partyPKHasBeenModified;
344    }
345    
346    @Nonnull
347    public ItemPK getItemPK() {
348        return itemPK;
349    }
350    
351    public void setItemPK(@Nonnull ItemPK itemPK)
352            throws PersistenceNotNullException {
353        checkForNull(itemPK);
354        
355        boolean update = true;
356        
357        if(this.itemPK != null) {
358            if(this.itemPK.equals(itemPK)) {
359                update = false;
360            }
361        } else if(itemPK == null) {
362            update = false;
363        }
364        
365        if(update) {
366            this.itemPK = itemPK;
367            itemPKHasBeenModified = true;
368            clearHashAndString();
369        }
370    }
371    
372    public boolean getItemPKHasBeenModified() {
373        return itemPKHasBeenModified;
374    }
375    
376    @Nonnull
377    public InventoryConditionPK getInventoryConditionPK() {
378        return inventoryConditionPK;
379    }
380    
381    public void setInventoryConditionPK(@Nonnull InventoryConditionPK inventoryConditionPK)
382            throws PersistenceNotNullException {
383        checkForNull(inventoryConditionPK);
384        
385        boolean update = true;
386        
387        if(this.inventoryConditionPK != null) {
388            if(this.inventoryConditionPK.equals(inventoryConditionPK)) {
389                update = false;
390            }
391        } else if(inventoryConditionPK == null) {
392            update = false;
393        }
394        
395        if(update) {
396            this.inventoryConditionPK = inventoryConditionPK;
397            inventoryConditionPKHasBeenModified = true;
398            clearHashAndString();
399        }
400    }
401    
402    public boolean getInventoryConditionPKHasBeenModified() {
403        return inventoryConditionPKHasBeenModified;
404    }
405    
406    @Nullable
407    public Long getMinimumInventory() {
408        return minimumInventory;
409    }
410    
411    public void setMinimumInventory(@Nullable Long minimumInventory) {
412        boolean update = true;
413        
414        if(this.minimumInventory != null) {
415            if(this.minimumInventory.equals(minimumInventory)) {
416                update = false;
417            }
418        } else if(minimumInventory == null) {
419            update = false;
420        }
421        
422        if(update) {
423            this.minimumInventory = minimumInventory;
424            minimumInventoryHasBeenModified = true;
425            clearHashAndString();
426        }
427    }
428    
429    public boolean getMinimumInventoryHasBeenModified() {
430        return minimumInventoryHasBeenModified;
431    }
432    
433    @Nullable
434    public Long getMaximumInventory() {
435        return maximumInventory;
436    }
437    
438    public void setMaximumInventory(@Nullable Long maximumInventory) {
439        boolean update = true;
440        
441        if(this.maximumInventory != null) {
442            if(this.maximumInventory.equals(maximumInventory)) {
443                update = false;
444            }
445        } else if(maximumInventory == null) {
446            update = false;
447        }
448        
449        if(update) {
450            this.maximumInventory = maximumInventory;
451            maximumInventoryHasBeenModified = true;
452            clearHashAndString();
453        }
454    }
455    
456    public boolean getMaximumInventoryHasBeenModified() {
457        return maximumInventoryHasBeenModified;
458    }
459    
460    @Nullable
461    public Long getReorderQuantity() {
462        return reorderQuantity;
463    }
464    
465    public void setReorderQuantity(@Nullable Long reorderQuantity) {
466        boolean update = true;
467        
468        if(this.reorderQuantity != null) {
469            if(this.reorderQuantity.equals(reorderQuantity)) {
470                update = false;
471            }
472        } else if(reorderQuantity == null) {
473            update = false;
474        }
475        
476        if(update) {
477            this.reorderQuantity = reorderQuantity;
478            reorderQuantityHasBeenModified = true;
479            clearHashAndString();
480        }
481    }
482    
483    public boolean getReorderQuantityHasBeenModified() {
484        return reorderQuantityHasBeenModified;
485    }
486    
487    @Nonnull
488    public Long getFromTime() {
489        return fromTime;
490    }
491    
492    public void setFromTime(@Nonnull Long fromTime)
493            throws PersistenceNotNullException {
494        checkForNull(fromTime);
495        
496        boolean update = true;
497        
498        if(this.fromTime != null) {
499            if(this.fromTime.equals(fromTime)) {
500                update = false;
501            }
502        } else if(fromTime == null) {
503            update = false;
504        }
505        
506        if(update) {
507            this.fromTime = fromTime;
508            fromTimeHasBeenModified = true;
509            clearHashAndString();
510        }
511    }
512    
513    public boolean getFromTimeHasBeenModified() {
514        return fromTimeHasBeenModified;
515    }
516    
517    @Nonnull
518    public Long getThruTime() {
519        return thruTime;
520    }
521    
522    public void setThruTime(@Nonnull Long thruTime)
523            throws PersistenceNotNullException {
524        checkForNull(thruTime);
525        
526        boolean update = true;
527        
528        if(this.thruTime != null) {
529            if(this.thruTime.equals(thruTime)) {
530                update = false;
531            }
532        } else if(thruTime == null) {
533            update = false;
534        }
535        
536        if(update) {
537            this.thruTime = thruTime;
538            thruTimeHasBeenModified = true;
539            clearHashAndString();
540        }
541    }
542    
543    public boolean getThruTimeHasBeenModified() {
544        return thruTimeHasBeenModified;
545    }
546    
547}