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