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 * MessageBlobValue.java
021 */
022
023package com.echothree.model.data.message.server.value;
024
025import com.echothree.model.data.message.common.pk.MessageBlobPK;
026
027import com.echothree.model.data.message.server.factory.MessageBlobFactory;
028
029import com.echothree.model.data.message.common.pk.MessagePK;
030import com.echothree.model.data.party.common.pk.LanguagePK;
031import com.echothree.model.data.core.common.pk.MimeTypePK;
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
040import javax.annotation.Nonnull;
041import javax.annotation.Nullable;
042
043import com.echothree.util.common.persistence.type.ByteArray;
044
045public class MessageBlobValue
046        extends BaseValue<MessageBlobPK>
047        implements Cloneable, Serializable {
048    
049    private MessagePK messagePK;
050    private boolean messagePKHasBeenModified = false;
051    private LanguagePK languagePK;
052    private boolean languagePKHasBeenModified = false;
053    private MimeTypePK mimeTypePK;
054    private boolean mimeTypePKHasBeenModified = false;
055    private ByteArray blob;
056    private boolean blobHasBeenModified = false;
057    private Long fromTime;
058    private boolean fromTimeHasBeenModified = false;
059    private Long thruTime;
060    private boolean thruTimeHasBeenModified = false;
061    
062    private transient Integer _hashCode = null;
063    private transient String _stringValue = null;
064    
065    private void constructFields(MessagePK messagePK, LanguagePK languagePK, MimeTypePK mimeTypePK, ByteArray blob, Long fromTime, Long thruTime)
066            throws PersistenceNotNullException {
067        checkForNull(messagePK);
068        this.messagePK = messagePK;
069        checkForNull(languagePK);
070        this.languagePK = languagePK;
071        this.mimeTypePK = mimeTypePK;
072        checkForNull(blob);
073        this.blob = blob;
074        checkForNull(fromTime);
075        this.fromTime = fromTime;
076        checkForNull(thruTime);
077        this.thruTime = thruTime;
078    }
079    
080    /** Creates a new instance of MessageBlobValue */
081    public MessageBlobValue(MessageBlobPK messageBlobPK, MessagePK messagePK, LanguagePK languagePK, MimeTypePK mimeTypePK, ByteArray blob, Long fromTime, Long thruTime)
082            throws PersistenceNotNullException {
083        super(messageBlobPK);
084        constructFields(messagePK, languagePK, mimeTypePK, blob, fromTime, thruTime);
085    }
086    
087    /** Creates a new instance of MessageBlobValue */
088    public MessageBlobValue(MessagePK messagePK, LanguagePK languagePK, MimeTypePK mimeTypePK, ByteArray blob, Long fromTime, Long thruTime)
089            throws PersistenceNotNullException {
090        super();
091        constructFields(messagePK, languagePK, mimeTypePK, blob, fromTime, thruTime);
092    }
093    
094    @Override
095    @Nonnull
096    public MessageBlobFactory getBaseFactoryInstance() {
097        return MessageBlobFactory.getInstance();
098    }
099    
100    @Override
101    @Nonnull
102    public MessageBlobValue clone() {
103        Object result;
104        
105        try {
106            result = super.clone();
107        } catch (CloneNotSupportedException cnse) {
108            // This shouldn't happen, fail when it does.
109            throw new PersistenceCloneException(cnse);
110        }
111        
112        return (MessageBlobValue)result;
113    }
114    
115    @Override
116    @Nonnull
117    public MessageBlobPK getPrimaryKey() {
118        if(_primaryKey == null) {
119            _primaryKey = new MessageBlobPK(entityId);
120        }
121        
122        return _primaryKey;
123    }
124    
125    private void clearHashAndString() {
126        _hashCode = null;
127        _stringValue = null;
128    }
129    
130    @Override
131    public int hashCode() {
132        if(_hashCode == null) {
133            int hashCode = 17;
134            
135            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
136            
137            hashCode = 37 * hashCode + ((messagePK != null) ? messagePK.hashCode() : 0);
138            hashCode = 37 * hashCode + ((languagePK != null) ? languagePK.hashCode() : 0);
139            hashCode = 37 * hashCode + ((mimeTypePK != null) ? mimeTypePK.hashCode() : 0);
140            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
141            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
142            
143            _hashCode = hashCode;
144        }
145        
146        return _hashCode;
147    }
148    
149    @Override
150    @Nonnull
151    public String toString() {
152        if(_stringValue == null) {
153            _stringValue = "{" + 
154                    "entityId=" + getEntityId() +
155                    ", messagePK=" + getMessagePK() +
156                    ", languagePK=" + getLanguagePK() +
157                    ", mimeTypePK=" + getMimeTypePK() +
158                    ", fromTime=" + getFromTime() +
159                    ", thruTime=" + getThruTime() +
160                    "}";
161        }
162        return _stringValue;
163    }
164    
165    @Override
166    public boolean equals(Object other) {
167        if(this == other)
168            return true;
169        
170        if(!hasIdentity())
171            return false;
172        
173        if(other instanceof  MessageBlobValue that) {
174            if(!that.hasIdentity())
175                return false;
176            
177            Long thisEntityId = getEntityId();
178            Long thatEntityId = that.getEntityId();
179            
180            boolean objectsEqual = thisEntityId.equals(thatEntityId);
181            if(objectsEqual)
182                objectsEqual = isIdentical(that);
183            
184            return objectsEqual;
185        } else {
186            return false;
187        }
188    }
189    
190    public boolean isIdentical(Object other) {
191        if(other instanceof MessageBlobValue that) {
192            boolean objectsEqual = true;
193            
194            
195            if(objectsEqual) {
196                MessagePK thisMessagePK = getMessagePK();
197                MessagePK thatMessagePK = that.getMessagePK();
198                
199                if(thisMessagePK == null) {
200                    objectsEqual = objectsEqual && (thatMessagePK == null);
201                } else {
202                    objectsEqual = objectsEqual && thisMessagePK.equals(thatMessagePK);
203                }
204            }
205            
206            if(objectsEqual) {
207                LanguagePK thisLanguagePK = getLanguagePK();
208                LanguagePK thatLanguagePK = that.getLanguagePK();
209                
210                if(thisLanguagePK == null) {
211                    objectsEqual = objectsEqual && (thatLanguagePK == null);
212                } else {
213                    objectsEqual = objectsEqual && thisLanguagePK.equals(thatLanguagePK);
214                }
215            }
216            
217            if(objectsEqual) {
218                MimeTypePK thisMimeTypePK = getMimeTypePK();
219                MimeTypePK thatMimeTypePK = that.getMimeTypePK();
220                
221                if(thisMimeTypePK == null) {
222                    objectsEqual = objectsEqual && (thatMimeTypePK == null);
223                } else {
224                    objectsEqual = objectsEqual && thisMimeTypePK.equals(thatMimeTypePK);
225                }
226            }
227            
228            if(objectsEqual) {
229                ByteArray thisBlob = getBlob();
230                ByteArray thatBlob = that.getBlob();
231                
232                if(thisBlob == null) {
233                    objectsEqual = objectsEqual && (thatBlob == null);
234                } else {
235                    objectsEqual = objectsEqual && thisBlob.equals(thatBlob);
236                }
237            }
238            
239            if(objectsEqual) {
240                Long thisFromTime = getFromTime();
241                Long thatFromTime = that.getFromTime();
242                
243                if(thisFromTime == null) {
244                    objectsEqual = objectsEqual && (thatFromTime == null);
245                } else {
246                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
247                }
248            }
249            
250            if(objectsEqual) {
251                Long thisThruTime = getThruTime();
252                Long thatThruTime = that.getThruTime();
253                
254                if(thisThruTime == null) {
255                    objectsEqual = objectsEqual && (thatThruTime == null);
256                } else {
257                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
258                }
259            }
260            
261            return objectsEqual;
262        } else {
263            return false;
264        }
265    }
266    
267    @Override
268    public boolean hasBeenModified() {
269        return messagePKHasBeenModified || languagePKHasBeenModified || mimeTypePKHasBeenModified || blobHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
270    }
271    
272    @Override
273    public void clearHasBeenModified() {
274        messagePKHasBeenModified = false;
275        languagePKHasBeenModified = false;
276        mimeTypePKHasBeenModified = false;
277        blobHasBeenModified = false;
278        fromTimeHasBeenModified = false;
279        thruTimeHasBeenModified = false;
280    }
281    
282    @Nonnull
283    public MessagePK getMessagePK() {
284        return messagePK;
285    }
286    
287    public void setMessagePK(@Nonnull MessagePK messagePK)
288            throws PersistenceNotNullException {
289        checkForNull(messagePK);
290        
291        boolean update = true;
292        
293        if(this.messagePK != null) {
294            if(this.messagePK.equals(messagePK)) {
295                update = false;
296            }
297        } else if(messagePK == null) {
298            update = false;
299        }
300        
301        if(update) {
302            this.messagePK = messagePK;
303            messagePKHasBeenModified = true;
304            clearHashAndString();
305        }
306    }
307    
308    public boolean getMessagePKHasBeenModified() {
309        return messagePKHasBeenModified;
310    }
311    
312    @Nonnull
313    public LanguagePK getLanguagePK() {
314        return languagePK;
315    }
316    
317    public void setLanguagePK(@Nonnull LanguagePK languagePK)
318            throws PersistenceNotNullException {
319        checkForNull(languagePK);
320        
321        boolean update = true;
322        
323        if(this.languagePK != null) {
324            if(this.languagePK.equals(languagePK)) {
325                update = false;
326            }
327        } else if(languagePK == null) {
328            update = false;
329        }
330        
331        if(update) {
332            this.languagePK = languagePK;
333            languagePKHasBeenModified = true;
334            clearHashAndString();
335        }
336    }
337    
338    public boolean getLanguagePKHasBeenModified() {
339        return languagePKHasBeenModified;
340    }
341    
342    @Nullable
343    public MimeTypePK getMimeTypePK() {
344        return mimeTypePK;
345    }
346    
347    public void setMimeTypePK(@Nullable MimeTypePK mimeTypePK) {
348        boolean update = true;
349        
350        if(this.mimeTypePK != null) {
351            if(this.mimeTypePK.equals(mimeTypePK)) {
352                update = false;
353            }
354        } else if(mimeTypePK == null) {
355            update = false;
356        }
357        
358        if(update) {
359            this.mimeTypePK = mimeTypePK;
360            mimeTypePKHasBeenModified = true;
361            clearHashAndString();
362        }
363    }
364    
365    public boolean getMimeTypePKHasBeenModified() {
366        return mimeTypePKHasBeenModified;
367    }
368    
369    @Nonnull
370    public ByteArray getBlob() {
371        return blob;
372    }
373    
374    public void setBlob(@Nonnull ByteArray blob)
375            throws PersistenceNotNullException {
376        checkForNull(blob);
377        
378        boolean update = true;
379        
380        if(this.blob != null) {
381            if(this.blob.equals(blob)) {
382                update = false;
383            }
384        } else if(blob == null) {
385            update = false;
386        }
387        
388        if(update) {
389            this.blob = blob;
390            blobHasBeenModified = true;
391            clearHashAndString();
392        }
393    }
394    
395    public boolean getBlobHasBeenModified() {
396        return blobHasBeenModified;
397    }
398    
399    @Nonnull
400    public Long getFromTime() {
401        return fromTime;
402    }
403    
404    public void setFromTime(@Nonnull Long fromTime)
405            throws PersistenceNotNullException {
406        checkForNull(fromTime);
407        
408        boolean update = true;
409        
410        if(this.fromTime != null) {
411            if(this.fromTime.equals(fromTime)) {
412                update = false;
413            }
414        } else if(fromTime == null) {
415            update = false;
416        }
417        
418        if(update) {
419            this.fromTime = fromTime;
420            fromTimeHasBeenModified = true;
421            clearHashAndString();
422        }
423    }
424    
425    public boolean getFromTimeHasBeenModified() {
426        return fromTimeHasBeenModified;
427    }
428    
429    @Nonnull
430    public Long getThruTime() {
431        return thruTime;
432    }
433    
434    public void setThruTime(@Nonnull Long thruTime)
435            throws PersistenceNotNullException {
436        checkForNull(thruTime);
437        
438        boolean update = true;
439        
440        if(this.thruTime != null) {
441            if(this.thruTime.equals(thruTime)) {
442                update = false;
443            }
444        } else if(thruTime == null) {
445            update = false;
446        }
447        
448        if(update) {
449            this.thruTime = thruTime;
450            thruTimeHasBeenModified = true;
451            clearHashAndString();
452        }
453    }
454    
455    public boolean getThruTimeHasBeenModified() {
456        return thruTimeHasBeenModified;
457    }
458    
459}