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