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