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