001// --------------------------------------------------------------------------------
002// Copyright 2002-2024 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 * PartyPaymentMethodContactMechanismValue.java
021 */
022
023package com.echothree.model.data.payment.server.value;
024
025import com.echothree.model.data.payment.common.pk.PartyPaymentMethodContactMechanismPK;
026
027import com.echothree.model.data.payment.server.factory.PartyPaymentMethodContactMechanismFactory;
028
029import com.echothree.model.data.payment.common.pk.PartyPaymentMethodPK;
030import com.echothree.model.data.contact.common.pk.PartyContactMechanismPurposePK;
031
032import com.echothree.util.common.exception.PersistenceCloneException;
033import com.echothree.util.common.exception.PersistenceNotNullException;
034
035import com.echothree.util.server.persistence.BaseValue;
036
037import java.io.Serializable;
038
039public class PartyPaymentMethodContactMechanismValue
040        extends BaseValue<PartyPaymentMethodContactMechanismPK>
041        implements Cloneable, Serializable {
042    
043    private PartyPaymentMethodPK partyPaymentMethodPK;
044    private boolean partyPaymentMethodPKHasBeenModified = false;
045    private PartyContactMechanismPurposePK partyContactMechanismPurposePK;
046    private boolean partyContactMechanismPurposePKHasBeenModified = false;
047    private Long fromTime;
048    private boolean fromTimeHasBeenModified = false;
049    private Long thruTime;
050    private boolean thruTimeHasBeenModified = false;
051    
052    private transient Integer _hashCode = null;
053    private transient String _stringValue = null;
054    
055    private void constructFields(PartyPaymentMethodPK partyPaymentMethodPK, PartyContactMechanismPurposePK partyContactMechanismPurposePK, Long fromTime, Long thruTime)
056            throws PersistenceNotNullException {
057        checkForNull(partyPaymentMethodPK);
058        this.partyPaymentMethodPK = partyPaymentMethodPK;
059        checkForNull(partyContactMechanismPurposePK);
060        this.partyContactMechanismPurposePK = partyContactMechanismPurposePK;
061        checkForNull(fromTime);
062        this.fromTime = fromTime;
063        checkForNull(thruTime);
064        this.thruTime = thruTime;
065    }
066    
067    /** Creates a new instance of PartyPaymentMethodContactMechanismValue */
068    public PartyPaymentMethodContactMechanismValue(PartyPaymentMethodContactMechanismPK partyPaymentMethodContactMechanismPK, PartyPaymentMethodPK partyPaymentMethodPK, PartyContactMechanismPurposePK partyContactMechanismPurposePK, Long fromTime, Long thruTime)
069            throws PersistenceNotNullException {
070        super(partyPaymentMethodContactMechanismPK);
071        constructFields(partyPaymentMethodPK, partyContactMechanismPurposePK, fromTime, thruTime);
072    }
073    
074    /** Creates a new instance of PartyPaymentMethodContactMechanismValue */
075    public PartyPaymentMethodContactMechanismValue(PartyPaymentMethodPK partyPaymentMethodPK, PartyContactMechanismPurposePK partyContactMechanismPurposePK, Long fromTime, Long thruTime)
076            throws PersistenceNotNullException {
077        super();
078        constructFields(partyPaymentMethodPK, partyContactMechanismPurposePK, fromTime, thruTime);
079    }
080    
081   @Override
082   public PartyPaymentMethodContactMechanismFactory getBaseFactoryInstance() {
083        return PartyPaymentMethodContactMechanismFactory.getInstance();
084    }
085    
086    @Override
087    public PartyPaymentMethodContactMechanismValue clone() {
088        Object result;
089        
090        try {
091            result = super.clone();
092        } catch (CloneNotSupportedException cnse) {
093            // This shouldn't happen, fail when it does.
094            throw new PersistenceCloneException(cnse);
095        }
096        
097        return (PartyPaymentMethodContactMechanismValue)result;
098    }
099    
100   @Override
101    public PartyPaymentMethodContactMechanismPK getPrimaryKey() {
102        if(_primaryKey == null) {
103            _primaryKey = new PartyPaymentMethodContactMechanismPK(entityId);
104        }
105        
106        return _primaryKey;
107    }
108    
109    private void clearHashAndString() {
110        _hashCode = null;
111        _stringValue = null;
112    }
113    
114    @Override
115    public int hashCode() {
116        if(_hashCode == null) {
117            int hashCode = 17;
118            
119            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
120            
121            hashCode = 37 * hashCode + ((partyPaymentMethodPK != null) ? partyPaymentMethodPK.hashCode() : 0);
122            hashCode = 37 * hashCode + ((partyContactMechanismPurposePK != null) ? partyContactMechanismPurposePK.hashCode() : 0);
123            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
124            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
125            
126            _hashCode = hashCode;
127        }
128        
129        return _hashCode;
130    }
131    
132    @Override
133    public String toString() {
134        if(_stringValue == null) {
135            StringBuilder stringValue = new StringBuilder("{");
136            
137            stringValue.append("entityId=").append(getEntityId());
138            
139            stringValue.append(", partyPaymentMethodPK=").append(getPartyPaymentMethodPK());
140            stringValue.append(", partyContactMechanismPurposePK=").append(getPartyContactMechanismPurposePK());
141            stringValue.append(", fromTime=").append(getFromTime());
142            stringValue.append(", thruTime=").append(getThruTime());
143            
144            stringValue.append('}');
145            
146            _stringValue = stringValue.toString();
147        }
148        return _stringValue;
149    }
150    
151    @Override
152    public boolean equals(Object other) {
153        if(this == other)
154            return true;
155        
156        if(!hasIdentity())
157            return false;
158        
159        if(other instanceof  PartyPaymentMethodContactMechanismValue) {
160            PartyPaymentMethodContactMechanismValue that = (PartyPaymentMethodContactMechanismValue)other;
161            
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 = 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 PartyPaymentMethodContactMechanismValue) {
180            PartyPaymentMethodContactMechanismValue that = (PartyPaymentMethodContactMechanismValue)other;
181            boolean objectsEqual = true;
182            
183            
184            if(objectsEqual) {
185                PartyPaymentMethodPK thisPartyPaymentMethodPK = getPartyPaymentMethodPK();
186                PartyPaymentMethodPK thatPartyPaymentMethodPK = that.getPartyPaymentMethodPK();
187                
188                if(thisPartyPaymentMethodPK == null) {
189                    objectsEqual = objectsEqual && (thatPartyPaymentMethodPK == null);
190                } else {
191                    objectsEqual = objectsEqual && thisPartyPaymentMethodPK.equals(thatPartyPaymentMethodPK);
192                }
193            }
194            
195            if(objectsEqual) {
196                PartyContactMechanismPurposePK thisPartyContactMechanismPurposePK = getPartyContactMechanismPurposePK();
197                PartyContactMechanismPurposePK thatPartyContactMechanismPurposePK = that.getPartyContactMechanismPurposePK();
198                
199                if(thisPartyContactMechanismPurposePK == null) {
200                    objectsEqual = objectsEqual && (thatPartyContactMechanismPurposePK == null);
201                } else {
202                    objectsEqual = objectsEqual && thisPartyContactMechanismPurposePK.equals(thatPartyContactMechanismPurposePK);
203                }
204            }
205            
206            if(objectsEqual) {
207                Long thisFromTime = getFromTime();
208                Long thatFromTime = that.getFromTime();
209                
210                if(thisFromTime == null) {
211                    objectsEqual = objectsEqual && (thatFromTime == null);
212                } else {
213                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
214                }
215            }
216            
217            if(objectsEqual) {
218                Long thisThruTime = getThruTime();
219                Long thatThruTime = that.getThruTime();
220                
221                if(thisThruTime == null) {
222                    objectsEqual = objectsEqual && (thatThruTime == null);
223                } else {
224                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
225                }
226            }
227            
228            return objectsEqual;
229        } else {
230            return false;
231        }
232    }
233    
234    @Override
235    public boolean hasBeenModified() {
236        return partyPaymentMethodPKHasBeenModified || partyContactMechanismPurposePKHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
237    }
238    
239    @Override
240    public void clearHasBeenModified() {
241        partyPaymentMethodPKHasBeenModified = false;
242        partyContactMechanismPurposePKHasBeenModified = false;
243        fromTimeHasBeenModified = false;
244        thruTimeHasBeenModified = false;
245    }
246    
247    public PartyPaymentMethodPK getPartyPaymentMethodPK() {
248        return partyPaymentMethodPK;
249    }
250    
251    public void setPartyPaymentMethodPK(PartyPaymentMethodPK partyPaymentMethodPK)
252            throws PersistenceNotNullException {
253        checkForNull(partyPaymentMethodPK);
254        
255        boolean update = true;
256        
257        if(this.partyPaymentMethodPK != null) {
258            if(this.partyPaymentMethodPK.equals(partyPaymentMethodPK)) {
259                update = false;
260            }
261        } else if(partyPaymentMethodPK == null) {
262            update = false;
263        }
264        
265        if(update) {
266            this.partyPaymentMethodPK = partyPaymentMethodPK;
267            partyPaymentMethodPKHasBeenModified = true;
268            clearHashAndString();
269        }
270    }
271    
272    public boolean getPartyPaymentMethodPKHasBeenModified() {
273        return partyPaymentMethodPKHasBeenModified;
274    }
275    
276    public PartyContactMechanismPurposePK getPartyContactMechanismPurposePK() {
277        return partyContactMechanismPurposePK;
278    }
279    
280    public void setPartyContactMechanismPurposePK(PartyContactMechanismPurposePK partyContactMechanismPurposePK)
281            throws PersistenceNotNullException {
282        checkForNull(partyContactMechanismPurposePK);
283        
284        boolean update = true;
285        
286        if(this.partyContactMechanismPurposePK != null) {
287            if(this.partyContactMechanismPurposePK.equals(partyContactMechanismPurposePK)) {
288                update = false;
289            }
290        } else if(partyContactMechanismPurposePK == null) {
291            update = false;
292        }
293        
294        if(update) {
295            this.partyContactMechanismPurposePK = partyContactMechanismPurposePK;
296            partyContactMechanismPurposePKHasBeenModified = true;
297            clearHashAndString();
298        }
299    }
300    
301    public boolean getPartyContactMechanismPurposePKHasBeenModified() {
302        return partyContactMechanismPurposePKHasBeenModified;
303    }
304    
305    public Long getFromTime() {
306        return fromTime;
307    }
308    
309    public void setFromTime(Long fromTime)
310            throws PersistenceNotNullException {
311        checkForNull(fromTime);
312        
313        boolean update = true;
314        
315        if(this.fromTime != null) {
316            if(this.fromTime.equals(fromTime)) {
317                update = false;
318            }
319        } else if(fromTime == null) {
320            update = false;
321        }
322        
323        if(update) {
324            this.fromTime = fromTime;
325            fromTimeHasBeenModified = true;
326            clearHashAndString();
327        }
328    }
329    
330    public boolean getFromTimeHasBeenModified() {
331        return fromTimeHasBeenModified;
332    }
333    
334    public Long getThruTime() {
335        return thruTime;
336    }
337    
338    public void setThruTime(Long thruTime)
339            throws PersistenceNotNullException {
340        checkForNull(thruTime);
341        
342        boolean update = true;
343        
344        if(this.thruTime != null) {
345            if(this.thruTime.equals(thruTime)) {
346                update = false;
347            }
348        } else if(thruTime == null) {
349            update = false;
350        }
351        
352        if(update) {
353            this.thruTime = thruTime;
354            thruTimeHasBeenModified = true;
355            clearHashAndString();
356        }
357    }
358    
359    public boolean getThruTimeHasBeenModified() {
360        return thruTimeHasBeenModified;
361    }
362    
363}