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 * InventoryTransactionLineRoleValue.java
021 */
022
023package com.echothree.model.data.inventory.server.value;
024
025import com.echothree.model.data.inventory.common.pk.InventoryTransactionLineRolePK;
026
027import com.echothree.model.data.inventory.server.factory.InventoryTransactionLineRoleFactory;
028
029import com.echothree.model.data.inventory.common.pk.InventoryTransactionLinePK;
030import com.echothree.model.data.inventory.common.pk.InventoryTransactionRoleTypePK;
031import com.echothree.model.data.party.common.pk.PartyPK;
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 InventoryTransactionLineRoleValue
044        extends BaseValue<InventoryTransactionLineRolePK>
045        implements Cloneable, Serializable {
046    
047    private InventoryTransactionLinePK inventoryTransactionLinePK;
048    private boolean inventoryTransactionLinePKHasBeenModified = false;
049    private InventoryTransactionRoleTypePK inventoryTransactionRoleTypePK;
050    private boolean inventoryTransactionRoleTypePKHasBeenModified = false;
051    private PartyPK partyPK;
052    private boolean partyPKHasBeenModified = false;
053    private Long fromTime;
054    private boolean fromTimeHasBeenModified = false;
055    private Long thruTime;
056    private boolean thruTimeHasBeenModified = false;
057    
058    private transient Integer _hashCode = null;
059    private transient String _stringValue = null;
060    
061    private void constructFields(InventoryTransactionLinePK inventoryTransactionLinePK, InventoryTransactionRoleTypePK inventoryTransactionRoleTypePK, PartyPK partyPK, Long fromTime, Long thruTime)
062            throws PersistenceNotNullException {
063        checkForNull(inventoryTransactionLinePK);
064        this.inventoryTransactionLinePK = inventoryTransactionLinePK;
065        checkForNull(inventoryTransactionRoleTypePK);
066        this.inventoryTransactionRoleTypePK = inventoryTransactionRoleTypePK;
067        checkForNull(partyPK);
068        this.partyPK = partyPK;
069        checkForNull(fromTime);
070        this.fromTime = fromTime;
071        checkForNull(thruTime);
072        this.thruTime = thruTime;
073    }
074    
075    /** Creates a new instance of InventoryTransactionLineRoleValue */
076    public InventoryTransactionLineRoleValue(InventoryTransactionLineRolePK inventoryTransactionLineRolePK, InventoryTransactionLinePK inventoryTransactionLinePK, InventoryTransactionRoleTypePK inventoryTransactionRoleTypePK, PartyPK partyPK, Long fromTime, Long thruTime)
077            throws PersistenceNotNullException {
078        super(inventoryTransactionLineRolePK);
079        constructFields(inventoryTransactionLinePK, inventoryTransactionRoleTypePK, partyPK, fromTime, thruTime);
080    }
081    
082    /** Creates a new instance of InventoryTransactionLineRoleValue */
083    public InventoryTransactionLineRoleValue(InventoryTransactionLinePK inventoryTransactionLinePK, InventoryTransactionRoleTypePK inventoryTransactionRoleTypePK, PartyPK partyPK, Long fromTime, Long thruTime)
084            throws PersistenceNotNullException {
085        super();
086        constructFields(inventoryTransactionLinePK, inventoryTransactionRoleTypePK, partyPK, fromTime, thruTime);
087    }
088    
089    @Override
090    @Nonnull
091    public InventoryTransactionLineRoleFactory getBaseFactoryInstance() {
092        return InventoryTransactionLineRoleFactory.getInstance();
093    }
094    
095    @Override
096    @Nonnull
097    public InventoryTransactionLineRoleValue clone() {
098        Object result;
099        
100        try {
101            result = super.clone();
102        } catch (CloneNotSupportedException cnse) {
103            // This shouldn't happen, fail when it does.
104            throw new PersistenceCloneException(cnse);
105        }
106        
107        return (InventoryTransactionLineRoleValue)result;
108    }
109    
110    @Override
111    @Nonnull
112    public InventoryTransactionLineRolePK getPrimaryKey() {
113        if(_primaryKey == null) {
114            _primaryKey = new InventoryTransactionLineRolePK(entityId);
115        }
116        
117        return _primaryKey;
118    }
119    
120    private void clearHashAndString() {
121        _hashCode = null;
122        _stringValue = null;
123    }
124    
125    @Override
126    public int hashCode() {
127        if(_hashCode == null) {
128            int hashCode = 17;
129            
130            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
131            
132            hashCode = 37 * hashCode + ((inventoryTransactionLinePK != null) ? inventoryTransactionLinePK.hashCode() : 0);
133            hashCode = 37 * hashCode + ((inventoryTransactionRoleTypePK != null) ? inventoryTransactionRoleTypePK.hashCode() : 0);
134            hashCode = 37 * hashCode + ((partyPK != null) ? partyPK.hashCode() : 0);
135            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
136            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
137            
138            _hashCode = hashCode;
139        }
140        
141        return _hashCode;
142    }
143    
144    @Override
145    @Nonnull
146    public String toString() {
147        if(_stringValue == null) {
148            _stringValue = "{" + 
149                    "entityId=" + getEntityId() +
150                    ", inventoryTransactionLinePK=" + getInventoryTransactionLinePK() +
151                    ", inventoryTransactionRoleTypePK=" + getInventoryTransactionRoleTypePK() +
152                    ", partyPK=" + getPartyPK() +
153                    ", fromTime=" + getFromTime() +
154                    ", thruTime=" + getThruTime() +
155                    "}";
156        }
157        return _stringValue;
158    }
159    
160    @Override
161    public boolean equals(Object other) {
162        if(this == other)
163            return true;
164        
165        if(!hasIdentity())
166            return false;
167        
168        if(other instanceof  InventoryTransactionLineRoleValue that) {
169            if(!that.hasIdentity())
170                return false;
171            
172            Long thisEntityId = getEntityId();
173            Long thatEntityId = that.getEntityId();
174            
175            boolean objectsEqual = thisEntityId.equals(thatEntityId);
176            if(objectsEqual)
177                objectsEqual = isIdentical(that);
178            
179            return objectsEqual;
180        } else {
181            return false;
182        }
183    }
184    
185    public boolean isIdentical(Object other) {
186        if(other instanceof InventoryTransactionLineRoleValue that) {
187            boolean objectsEqual = true;
188            
189            
190            if(objectsEqual) {
191                InventoryTransactionLinePK thisInventoryTransactionLinePK = getInventoryTransactionLinePK();
192                InventoryTransactionLinePK thatInventoryTransactionLinePK = that.getInventoryTransactionLinePK();
193                
194                if(thisInventoryTransactionLinePK == null) {
195                    objectsEqual = objectsEqual && (thatInventoryTransactionLinePK == null);
196                } else {
197                    objectsEqual = objectsEqual && thisInventoryTransactionLinePK.equals(thatInventoryTransactionLinePK);
198                }
199            }
200            
201            if(objectsEqual) {
202                InventoryTransactionRoleTypePK thisInventoryTransactionRoleTypePK = getInventoryTransactionRoleTypePK();
203                InventoryTransactionRoleTypePK thatInventoryTransactionRoleTypePK = that.getInventoryTransactionRoleTypePK();
204                
205                if(thisInventoryTransactionRoleTypePK == null) {
206                    objectsEqual = objectsEqual && (thatInventoryTransactionRoleTypePK == null);
207                } else {
208                    objectsEqual = objectsEqual && thisInventoryTransactionRoleTypePK.equals(thatInventoryTransactionRoleTypePK);
209                }
210            }
211            
212            if(objectsEqual) {
213                PartyPK thisPartyPK = getPartyPK();
214                PartyPK thatPartyPK = that.getPartyPK();
215                
216                if(thisPartyPK == null) {
217                    objectsEqual = objectsEqual && (thatPartyPK == null);
218                } else {
219                    objectsEqual = objectsEqual && thisPartyPK.equals(thatPartyPK);
220                }
221            }
222            
223            if(objectsEqual) {
224                Long thisFromTime = getFromTime();
225                Long thatFromTime = that.getFromTime();
226                
227                if(thisFromTime == null) {
228                    objectsEqual = objectsEqual && (thatFromTime == null);
229                } else {
230                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
231                }
232            }
233            
234            if(objectsEqual) {
235                Long thisThruTime = getThruTime();
236                Long thatThruTime = that.getThruTime();
237                
238                if(thisThruTime == null) {
239                    objectsEqual = objectsEqual && (thatThruTime == null);
240                } else {
241                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
242                }
243            }
244            
245            return objectsEqual;
246        } else {
247            return false;
248        }
249    }
250    
251    @Override
252    public boolean hasBeenModified() {
253        return inventoryTransactionLinePKHasBeenModified || inventoryTransactionRoleTypePKHasBeenModified || partyPKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
254    }
255    
256    @Override
257    public void clearHasBeenModified() {
258        inventoryTransactionLinePKHasBeenModified = false;
259        inventoryTransactionRoleTypePKHasBeenModified = false;
260        partyPKHasBeenModified = false;
261        fromTimeHasBeenModified = false;
262        thruTimeHasBeenModified = false;
263    }
264    
265    @Nonnull
266    public InventoryTransactionLinePK getInventoryTransactionLinePK() {
267        return inventoryTransactionLinePK;
268    }
269    
270    public void setInventoryTransactionLinePK(@Nonnull InventoryTransactionLinePK inventoryTransactionLinePK)
271            throws PersistenceNotNullException {
272        checkForNull(inventoryTransactionLinePK);
273        
274        boolean update = true;
275        
276        if(this.inventoryTransactionLinePK != null) {
277            if(this.inventoryTransactionLinePK.equals(inventoryTransactionLinePK)) {
278                update = false;
279            }
280        } else if(inventoryTransactionLinePK == null) {
281            update = false;
282        }
283        
284        if(update) {
285            this.inventoryTransactionLinePK = inventoryTransactionLinePK;
286            inventoryTransactionLinePKHasBeenModified = true;
287            clearHashAndString();
288        }
289    }
290    
291    public boolean getInventoryTransactionLinePKHasBeenModified() {
292        return inventoryTransactionLinePKHasBeenModified;
293    }
294    
295    @Nonnull
296    public InventoryTransactionRoleTypePK getInventoryTransactionRoleTypePK() {
297        return inventoryTransactionRoleTypePK;
298    }
299    
300    public void setInventoryTransactionRoleTypePK(@Nonnull InventoryTransactionRoleTypePK inventoryTransactionRoleTypePK)
301            throws PersistenceNotNullException {
302        checkForNull(inventoryTransactionRoleTypePK);
303        
304        boolean update = true;
305        
306        if(this.inventoryTransactionRoleTypePK != null) {
307            if(this.inventoryTransactionRoleTypePK.equals(inventoryTransactionRoleTypePK)) {
308                update = false;
309            }
310        } else if(inventoryTransactionRoleTypePK == null) {
311            update = false;
312        }
313        
314        if(update) {
315            this.inventoryTransactionRoleTypePK = inventoryTransactionRoleTypePK;
316            inventoryTransactionRoleTypePKHasBeenModified = true;
317            clearHashAndString();
318        }
319    }
320    
321    public boolean getInventoryTransactionRoleTypePKHasBeenModified() {
322        return inventoryTransactionRoleTypePKHasBeenModified;
323    }
324    
325    @Nonnull
326    public PartyPK getPartyPK() {
327        return partyPK;
328    }
329    
330    public void setPartyPK(@Nonnull PartyPK partyPK)
331            throws PersistenceNotNullException {
332        checkForNull(partyPK);
333        
334        boolean update = true;
335        
336        if(this.partyPK != null) {
337            if(this.partyPK.equals(partyPK)) {
338                update = false;
339            }
340        } else if(partyPK == null) {
341            update = false;
342        }
343        
344        if(update) {
345            this.partyPK = partyPK;
346            partyPKHasBeenModified = true;
347            clearHashAndString();
348        }
349    }
350    
351    public boolean getPartyPKHasBeenModified() {
352        return partyPKHasBeenModified;
353    }
354    
355    @Nonnull
356    public Long getFromTime() {
357        return fromTime;
358    }
359    
360    public void setFromTime(@Nonnull Long fromTime)
361            throws PersistenceNotNullException {
362        checkForNull(fromTime);
363        
364        boolean update = true;
365        
366        if(this.fromTime != null) {
367            if(this.fromTime.equals(fromTime)) {
368                update = false;
369            }
370        } else if(fromTime == null) {
371            update = false;
372        }
373        
374        if(update) {
375            this.fromTime = fromTime;
376            fromTimeHasBeenModified = true;
377            clearHashAndString();
378        }
379    }
380    
381    public boolean getFromTimeHasBeenModified() {
382        return fromTimeHasBeenModified;
383    }
384    
385    @Nonnull
386    public Long getThruTime() {
387        return thruTime;
388    }
389    
390    public void setThruTime(@Nonnull Long thruTime)
391            throws PersistenceNotNullException {
392        checkForNull(thruTime);
393        
394        boolean update = true;
395        
396        if(this.thruTime != null) {
397            if(this.thruTime.equals(thruTime)) {
398                update = false;
399            }
400        } else if(thruTime == null) {
401            update = false;
402        }
403        
404        if(update) {
405            this.thruTime = thruTime;
406            thruTimeHasBeenModified = true;
407            clearHashAndString();
408        }
409    }
410    
411    public boolean getThruTimeHasBeenModified() {
412        return thruTimeHasBeenModified;
413    }
414    
415}