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