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