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