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