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