001// ______________________________________________________
002// Generated by sql2java - https://github.com/10km/sql2java-2-6-7 (custom branch) 
003// modified by guyadong from
004// sql2java original version https://sourceforge.net/projects/sql2java/ 
005// JDBC driver used at code generation time: com.mysql.jdbc.Driver
006// template: bean.java.vm
007// ______________________________________________________
008package net.gdface.facelog.db;
009import java.io.Serializable;
010import java.util.List;
011import java.util.Objects;
012
013import com.facebook.swift.codec.ThriftStruct;
014import com.facebook.swift.codec.ThriftField;
015import com.facebook.swift.codec.ThriftField.Requiredness;
016import io.swagger.annotations.ApiModel;
017import io.swagger.annotations.ApiModelProperty;
018/**
019 * LogLightBean is a mapping of fl_log_light Table.
020 * <br>Meta Data Information (in progress):
021 * <ul>
022 *    <li>comments: VIEW </li>
023 * </ul>
024 * @author guyadong
025*/
026@ThriftStruct
027@ApiModel(description="VIEW")
028public final class LogLightBean
029    implements Serializable,BaseBean<LogLightBean>,Comparable<LogLightBean>,Constant,Cloneable
030{
031    private static final long serialVersionUID = 4419196843551738129L;
032    /** NULL {@link LogLightBean} bean , IMMUTABLE instance */
033    public static final LogLightBean NULL = new LogLightBean().asNULL().asImmutable();
034    /** comments:日志id */
035    @ApiModelProperty(value = "日志id"  ,dataType="Integer")
036    private Integer id;
037
038    /** comments:用户id */
039    @ApiModelProperty(value = "用户id"  ,dataType="Integer")
040    private Integer personId;
041
042    /** comments:姓名 */
043    @ApiModelProperty(value = "姓名" ,required=true ,dataType="String")
044    private String name;
045
046    /** comments:证件类型,0:未知,1:身份证,2:护照,3:台胞证,4:港澳通行证,5:军官证,6:外国人居留证,7:员工卡,8:其他 */
047    @ApiModelProperty(value = "证件类型,0:未知,1:身份证,2:护照,3:台胞证,4:港澳通行证,5:军官证,6:外国人居留证,7:员工卡,8:其他"  ,dataType="Integer")
048    private Integer papersType;
049
050    /** comments:证件号码 */
051    @ApiModelProperty(value = "证件号码"  ,dataType="String")
052    private String papersNum;
053
054    /** comments:验证时间(可能由前端设备提供时间) */
055    @ApiModelProperty(value = "验证时间(可能由前端设备提供时间)"  ,dataType="Date")
056    private java.util.Date verifyTime;
057
058    /** comments:通行方向,NULL,0:入口,1:出口,默认0 */
059    @ApiModelProperty(value = "通行方向,NULL,0:入口,1:出口,默认0"  ,dataType="Integer")
060    private Integer direction;
061
062    /** flag whether {@code this} can be modified */
063    private Boolean immutable;
064    /** columns modified flag */
065    @ApiModelProperty(value="columns modified flag",dataType="int",required=true)
066    private int modified;
067    /** columns initialized flag */
068    @ApiModelProperty(value="columns initialized flag",dataType="int",required=true)
069    private int initialized;
070    /** new record flag  */
071    @ApiModelProperty(value="new record flag",dataType="boolean",required=true)
072    private boolean isNew;        
073    /** 
074     * set immutable status
075     * @return {@code this} 
076     */
077    private LogLightBean immutable(Boolean immutable) {
078        this.immutable = immutable;
079        return this;
080    }
081    /** 
082     * set {@code this} as immutable object
083     * @return {@code this} 
084     */
085    public LogLightBean asImmutable() {
086        return immutable(Boolean.TRUE);
087    }
088    /**
089     * @return {@code true} if {@code this} is a mutable object  
090     */
091    public boolean mutable(){
092        return !Boolean.TRUE.equals(this.immutable);
093    }
094    /**
095     * @return {@code this}
096     * @throws IllegalStateException if {@code this} is a immutable object 
097     */
098    private LogLightBean checkMutable(){
099        if(!mutable()){
100            throw new IllegalStateException("this is a immutable object");
101        }
102        return this;
103    }
104    /**
105     * @return return a new mutable copy of this object.
106     */
107    public LogLightBean cloneMutable(){
108        return clone().immutable(null);
109    }
110    @ThriftField(value=1,name="_new",requiredness=Requiredness.REQUIRED)
111    @Override
112    public boolean isNew()
113    {
114        return this.isNew;
115    }
116
117
118    @Override
119    public void isNew(boolean isNew)
120    {
121        this.isNew = isNew;
122    }
123    /**
124     * Specifies to the object if it has been set as new.
125     *
126     * @param isNew the boolean value to be assigned to the isNew field
127     */
128    @ThriftField()
129    public void setNew(boolean isNew)
130    {
131        this.isNew = isNew;
132    }
133    /**
134     * @return the modified status of columns
135     */
136    @ThriftField(value=2,requiredness=Requiredness.REQUIRED)
137    public int getModified(){
138        return modified;
139    }
140
141    /**
142     * @param modified the modified status bit to be assigned to {@link #modified}
143     */
144    @ThriftField()
145    public void setModified(int modified){
146        this.modified = modified;
147    }
148    /**
149     * @return the initialized status of columns
150     */
151    @ThriftField(value=3,requiredness=Requiredness.REQUIRED)
152    public int getInitialized(){
153        return initialized;
154    }
155
156    /**
157     * @param initialized the initialized status bit to be assigned to {@link #initialized}
158     */
159    @ThriftField()
160    public void setInitialized(int initialized){
161        this.initialized = initialized;
162    }
163    protected static final <T extends Comparable<T>>boolean equals(T a, T b) {
164        return a == b || (a != null && 0==a.compareTo(b));
165    }
166    public LogLightBean(){
167        super();
168        reset();
169    }
170    /**
171     * Getter method for {@link #id}.<br>
172     * Meta Data Information (in progress):
173     * <ul>
174     * <li>full name: fl_log_light.id</li>
175     * <li>comments: 日志id</li>
176     * <li>default value: '0'</li>
177     * <li>NOT NULL</li>
178     * <li>column size: 10</li>
179     * <li>JDBC type returned by the driver: Types.INTEGER</li>
180     * </ul>
181     *
182     * @return the value of id
183     */
184    @ThriftField(value=4)
185    public Integer getId(){
186        return id;
187    }
188    /**
189     * Setter method for {@link #id}.<br>
190     * The new value is set only if equals() says it is different,
191     * or if one of either the new value or the current value is null.
192     * In case the new value is different, it is set and the field is marked as 'modified'.
193     *
194     * @param newVal the new value( NOT NULL) to be assigned to id
195     */
196    public void setId(Integer newVal)
197    {
198        checkMutable();
199
200        modified |= FL_LOG_LIGHT_ID_ID_MASK;
201        initialized |= FL_LOG_LIGHT_ID_ID_MASK;
202
203        if (Objects.equals(newVal, id)) {
204            return;
205        }
206        id = newVal;
207    }
208    /** 
209     * setter for thrift:swift support<br>
210     * without modification for {@link #modified} and {@link #initialized}<br>
211     * <b>NOTE:</b>DO NOT use the method in your code
212     */
213    @ThriftField(name = "id")
214    public void writeId(Integer newVal){
215        checkMutable();
216        id = newVal;
217    }
218    /**
219     * Setter method for {@link #id}.<br>
220     * Convenient for those who do not want to deal with Objects for primary types.
221     *
222     * @param newVal the new value to be assigned to id
223     */
224    public void setId(int newVal)
225    {
226        setId(new Integer(newVal));
227    }
228    /**
229     * Determines if the id has been modified.
230     *
231     * @return true if the field has been modified, false if the field has not been modified
232     */
233    public boolean checkIdModified()
234    {
235        return 0L !=  (modified & FL_LOG_LIGHT_ID_ID_MASK);
236    }
237
238    /**
239     * Determines if the id has been initialized.<br>
240     *
241     * It is useful to determine if a field is null on purpose or just because it has not been initialized.
242     *
243     * @return true if the field has been initialized, false otherwise
244     */
245    public boolean checkIdInitialized()
246    {
247        return 0L !=  (initialized & FL_LOG_LIGHT_ID_ID_MASK);
248    }
249    /**
250     * Getter method for {@link #personId}.<br>
251     * Meta Data Information (in progress):
252     * <ul>
253     * <li>full name: fl_log_light.person_id</li>
254     * <li>comments: 用户id</li>
255     * <li>default value: '0'</li>
256     * <li>NOT NULL</li>
257     * <li>column size: 10</li>
258     * <li>JDBC type returned by the driver: Types.INTEGER</li>
259     * </ul>
260     *
261     * @return the value of personId
262     */
263    @ThriftField(value=5)
264    public Integer getPersonId(){
265        return personId;
266    }
267    /**
268     * Setter method for {@link #personId}.<br>
269     * The new value is set only if equals() says it is different,
270     * or if one of either the new value or the current value is null.
271     * In case the new value is different, it is set and the field is marked as 'modified'.
272     *
273     * @param newVal the new value( NOT NULL) to be assigned to personId
274     */
275    public void setPersonId(Integer newVal)
276    {
277        checkMutable();
278
279        modified |= FL_LOG_LIGHT_ID_PERSON_ID_MASK;
280        initialized |= FL_LOG_LIGHT_ID_PERSON_ID_MASK;
281
282        if (Objects.equals(newVal, personId)) {
283            return;
284        }
285        personId = newVal;
286    }
287    /** 
288     * setter for thrift:swift support<br>
289     * without modification for {@link #modified} and {@link #initialized}<br>
290     * <b>NOTE:</b>DO NOT use the method in your code
291     */
292    @ThriftField(name = "personId")
293    public void writePersonId(Integer newVal){
294        checkMutable();
295        personId = newVal;
296    }
297    /**
298     * Setter method for {@link #personId}.<br>
299     * Convenient for those who do not want to deal with Objects for primary types.
300     *
301     * @param newVal the new value to be assigned to personId
302     */
303    public void setPersonId(int newVal)
304    {
305        setPersonId(new Integer(newVal));
306    }
307    /**
308     * Determines if the personId has been modified.
309     *
310     * @return true if the field has been modified, false if the field has not been modified
311     */
312    public boolean checkPersonIdModified()
313    {
314        return 0L !=  (modified & FL_LOG_LIGHT_ID_PERSON_ID_MASK);
315    }
316
317    /**
318     * Determines if the personId has been initialized.<br>
319     *
320     * It is useful to determine if a field is null on purpose or just because it has not been initialized.
321     *
322     * @return true if the field has been initialized, false otherwise
323     */
324    public boolean checkPersonIdInitialized()
325    {
326        return 0L !=  (initialized & FL_LOG_LIGHT_ID_PERSON_ID_MASK);
327    }
328    /**
329     * Getter method for {@link #name}.<br>
330     * Meta Data Information (in progress):
331     * <ul>
332     * <li>full name: fl_log_light.name</li>
333     * <li>comments: 姓名</li>
334     * <li>NOT NULL</li>
335     * <li>column size: 32</li>
336     * <li>JDBC type returned by the driver: Types.VARCHAR</li>
337     * </ul>
338     *
339     * @return the value of name
340     */
341    @ThriftField(value=6)
342    public String getName(){
343        return name;
344    }
345    /**
346     * Setter method for {@link #name}.<br>
347     * The new value is set only if equals() says it is different,
348     * or if one of either the new value or the current value is null.
349     * In case the new value is different, it is set and the field is marked as 'modified'.
350     *
351     * @param newVal the new value( NOT NULL) to be assigned to name
352     */
353    public void setName(String newVal)
354    {
355        checkMutable();
356
357        modified |= FL_LOG_LIGHT_ID_NAME_MASK;
358        initialized |= FL_LOG_LIGHT_ID_NAME_MASK;
359
360        if (Objects.equals(newVal, name)) {
361            return;
362        }
363        name = newVal;
364    }
365    /** 
366     * setter for thrift:swift support<br>
367     * without modification for {@link #modified} and {@link #initialized}<br>
368     * <b>NOTE:</b>DO NOT use the method in your code
369     */
370    @ThriftField(name = "name")
371    public void writeName(String newVal){
372        checkMutable();
373        name = newVal;
374    }
375    /**
376     * Determines if the name has been modified.
377     *
378     * @return true if the field has been modified, false if the field has not been modified
379     */
380    public boolean checkNameModified()
381    {
382        return 0L !=  (modified & FL_LOG_LIGHT_ID_NAME_MASK);
383    }
384
385    /**
386     * Determines if the name has been initialized.<br>
387     *
388     * It is useful to determine if a field is null on purpose or just because it has not been initialized.
389     *
390     * @return true if the field has been initialized, false otherwise
391     */
392    public boolean checkNameInitialized()
393    {
394        return 0L !=  (initialized & FL_LOG_LIGHT_ID_NAME_MASK);
395    }
396    /**
397     * Getter method for {@link #papersType}.<br>
398     * Meta Data Information (in progress):
399     * <ul>
400     * <li>full name: fl_log_light.papers_type</li>
401     * <li>comments: 证件类型,0:未知,1:身份证,2:护照,3:台胞证,4:港澳通行证,5:军官证,6:外国人居留证,7:员工卡,8:其他</li>
402     * <li>column size: 3</li>
403     * <li>JDBC type returned by the driver: Types.TINYINT</li>
404     * </ul>
405     *
406     * @return the value of papersType
407     */
408    @ThriftField(value=7)
409    public Integer getPapersType(){
410        return papersType;
411    }
412    /**
413     * Setter method for {@link #papersType}.<br>
414     * The new value is set only if equals() says it is different,
415     * or if one of either the new value or the current value is null.
416     * In case the new value is different, it is set and the field is marked as 'modified'.
417     *
418     * @param newVal the new value to be assigned to papersType
419     */
420    public void setPapersType(Integer newVal)
421    {
422        checkMutable();
423
424        modified |= FL_LOG_LIGHT_ID_PAPERS_TYPE_MASK;
425        initialized |= FL_LOG_LIGHT_ID_PAPERS_TYPE_MASK;
426
427        if (Objects.equals(newVal, papersType)) {
428            return;
429        }
430        papersType = newVal;
431    }
432    /** 
433     * setter for thrift:swift support<br>
434     * without modification for {@link #modified} and {@link #initialized}<br>
435     * <b>NOTE:</b>DO NOT use the method in your code
436     */
437    @ThriftField(name = "papersType")
438    public void writePapersType(Integer newVal){
439        checkMutable();
440        papersType = newVal;
441    }
442    /**
443     * Setter method for {@link #papersType}.<br>
444     * Convenient for those who do not want to deal with Objects for primary types.
445     *
446     * @param newVal the new value to be assigned to papersType
447     */
448    public void setPapersType(int newVal)
449    {
450        setPapersType(new Integer(newVal));
451    }
452    /**
453     * Determines if the papersType has been modified.
454     *
455     * @return true if the field has been modified, false if the field has not been modified
456     */
457    public boolean checkPapersTypeModified()
458    {
459        return 0L !=  (modified & FL_LOG_LIGHT_ID_PAPERS_TYPE_MASK);
460    }
461
462    /**
463     * Determines if the papersType has been initialized.<br>
464     *
465     * It is useful to determine if a field is null on purpose or just because it has not been initialized.
466     *
467     * @return true if the field has been initialized, false otherwise
468     */
469    public boolean checkPapersTypeInitialized()
470    {
471        return 0L !=  (initialized & FL_LOG_LIGHT_ID_PAPERS_TYPE_MASK);
472    }
473    /**
474     * Getter method for {@link #papersNum}.<br>
475     * Meta Data Information (in progress):
476     * <ul>
477     * <li>full name: fl_log_light.papers_num</li>
478     * <li>comments: 证件号码</li>
479     * <li>column size: 32</li>
480     * <li>JDBC type returned by the driver: Types.VARCHAR</li>
481     * </ul>
482     *
483     * @return the value of papersNum
484     */
485    @ThriftField(value=8)
486    public String getPapersNum(){
487        return papersNum;
488    }
489    /**
490     * Setter method for {@link #papersNum}.<br>
491     * The new value is set only if equals() says it is different,
492     * or if one of either the new value or the current value is null.
493     * In case the new value is different, it is set and the field is marked as 'modified'.
494     *
495     * @param newVal the new value to be assigned to papersNum
496     */
497    public void setPapersNum(String newVal)
498    {
499        checkMutable();
500
501        modified |= FL_LOG_LIGHT_ID_PAPERS_NUM_MASK;
502        initialized |= FL_LOG_LIGHT_ID_PAPERS_NUM_MASK;
503
504        if (Objects.equals(newVal, papersNum)) {
505            return;
506        }
507        papersNum = newVal;
508    }
509    /** 
510     * setter for thrift:swift support<br>
511     * without modification for {@link #modified} and {@link #initialized}<br>
512     * <b>NOTE:</b>DO NOT use the method in your code
513     */
514    @ThriftField(name = "papersNum")
515    public void writePapersNum(String newVal){
516        checkMutable();
517        papersNum = newVal;
518    }
519    /**
520     * Determines if the papersNum has been modified.
521     *
522     * @return true if the field has been modified, false if the field has not been modified
523     */
524    public boolean checkPapersNumModified()
525    {
526        return 0L !=  (modified & FL_LOG_LIGHT_ID_PAPERS_NUM_MASK);
527    }
528
529    /**
530     * Determines if the papersNum has been initialized.<br>
531     *
532     * It is useful to determine if a field is null on purpose or just because it has not been initialized.
533     *
534     * @return true if the field has been initialized, false otherwise
535     */
536    public boolean checkPapersNumInitialized()
537    {
538        return 0L !=  (initialized & FL_LOG_LIGHT_ID_PAPERS_NUM_MASK);
539    }
540    /**
541     * Getter method for {@link #verifyTime}.<br>
542     * Meta Data Information (in progress):
543     * <ul>
544     * <li>full name: fl_log_light.verify_time</li>
545     * <li>comments: 验证时间(可能由前端设备提供时间)</li>
546     * <li>default value: '0000-00-00 00:00:00'</li>
547     * <li>NOT NULL</li>
548     * <li>column size: 19</li>
549     * <li>JDBC type returned by the driver: Types.TIMESTAMP</li>
550     * </ul>
551     *
552     * @return the value of verifyTime
553     */
554    public java.util.Date getVerifyTime(){
555        return verifyTime;
556    }
557    /** 
558     * use Long to represent date type for thrift:swift support 
559     * @see #getVerifyTime()
560     */
561    @ThriftField(name = "verifyTime",value = 9)
562    public Long readVerifyTime(){
563        return null == verifyTime ? null:verifyTime.getTime();
564    }
565    /**
566     * Setter method for {@link #verifyTime}.<br>
567     * The new value is set only if equals() says it is different,
568     * or if one of either the new value or the current value is null.
569     * In case the new value is different, it is set and the field is marked as 'modified'.
570     *
571     * @param newVal the new value( NOT NULL) to be assigned to verifyTime
572     */
573    public void setVerifyTime(java.util.Date newVal)
574    {
575        checkMutable();
576
577        modified |= FL_LOG_LIGHT_ID_VERIFY_TIME_MASK;
578        initialized |= FL_LOG_LIGHT_ID_VERIFY_TIME_MASK;
579
580        if (Objects.equals(newVal, verifyTime)) {
581            return;
582        }
583        verifyTime = newVal;
584    }
585    /** 
586     * setter for thrift:swift support<br>
587     * without modification for {@link #modified} and {@link #initialized}<br>
588     * <b>NOTE:</b>DO NOT use the method in your code
589     */
590    @ThriftField(name = "verifyTime")
591    public void writeVerifyTime(Long newVal){
592        checkMutable();
593        verifyTime = null == newVal?null:new java.util.Date(newVal);
594    }
595    /**
596     * Setter method for {@link #verifyTime}.<br>
597     * Convenient for those who do not want to deal with Objects for primary types.
598     *
599     * @param newVal the new value to be assigned to verifyTime
600     */
601    public void setVerifyTime(long newVal)
602    {
603        setVerifyTime(new java.util.Date(newVal));
604    }
605    /**
606     * Setter method for {@link #verifyTime}.<br>
607     * @param newVal the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.
608     */
609    public void setVerifyTime(Long newVal)
610    {
611        setVerifyTime(null == newVal ? null : new java.util.Date(newVal));
612    }
613    /**
614     * Determines if the verifyTime has been modified.
615     *
616     * @return true if the field has been modified, false if the field has not been modified
617     */
618    public boolean checkVerifyTimeModified()
619    {
620        return 0L !=  (modified & FL_LOG_LIGHT_ID_VERIFY_TIME_MASK);
621    }
622
623    /**
624     * Determines if the verifyTime has been initialized.<br>
625     *
626     * It is useful to determine if a field is null on purpose or just because it has not been initialized.
627     *
628     * @return true if the field has been initialized, false otherwise
629     */
630    public boolean checkVerifyTimeInitialized()
631    {
632        return 0L !=  (initialized & FL_LOG_LIGHT_ID_VERIFY_TIME_MASK);
633    }
634    /**
635     * Getter method for {@link #direction}.<br>
636     * Meta Data Information (in progress):
637     * <ul>
638     * <li>full name: fl_log_light.direction</li>
639     * <li>comments: 通行方向,NULL,0:入口,1:出口,默认0</li>
640     * <li>column size: 10</li>
641     * <li>JDBC type returned by the driver: Types.INTEGER</li>
642     * </ul>
643     *
644     * @return the value of direction
645     */
646    @ThriftField(value=10)
647    public Integer getDirection(){
648        return direction;
649    }
650    /**
651     * Setter method for {@link #direction}.<br>
652     * The new value is set only if equals() says it is different,
653     * or if one of either the new value or the current value is null.
654     * In case the new value is different, it is set and the field is marked as 'modified'.
655     *
656     * @param newVal the new value to be assigned to direction
657     */
658    public void setDirection(Integer newVal)
659    {
660        checkMutable();
661
662        modified |= FL_LOG_LIGHT_ID_DIRECTION_MASK;
663        initialized |= FL_LOG_LIGHT_ID_DIRECTION_MASK;
664
665        if (Objects.equals(newVal, direction)) {
666            return;
667        }
668        direction = newVal;
669    }
670    /** 
671     * setter for thrift:swift support<br>
672     * without modification for {@link #modified} and {@link #initialized}<br>
673     * <b>NOTE:</b>DO NOT use the method in your code
674     */
675    @ThriftField(name = "direction")
676    public void writeDirection(Integer newVal){
677        checkMutable();
678        direction = newVal;
679    }
680    /**
681     * Setter method for {@link #direction}.<br>
682     * Convenient for those who do not want to deal with Objects for primary types.
683     *
684     * @param newVal the new value to be assigned to direction
685     */
686    public void setDirection(int newVal)
687    {
688        setDirection(new Integer(newVal));
689    }
690    /**
691     * Determines if the direction has been modified.
692     *
693     * @return true if the field has been modified, false if the field has not been modified
694     */
695    public boolean checkDirectionModified()
696    {
697        return 0L !=  (modified & FL_LOG_LIGHT_ID_DIRECTION_MASK);
698    }
699
700    /**
701     * Determines if the direction has been initialized.<br>
702     *
703     * It is useful to determine if a field is null on purpose or just because it has not been initialized.
704     *
705     * @return true if the field has been initialized, false otherwise
706     */
707    public boolean checkDirectionInitialized()
708    {
709        return 0L !=  (initialized & FL_LOG_LIGHT_ID_DIRECTION_MASK);
710    }
711
712    @Override
713    public boolean isModified()
714    {
715        return 0 != modified;
716    }
717  
718    @Override
719    public boolean isModified(int columnID){
720        switch ( columnID ){
721        case FL_LOG_LIGHT_ID_ID:
722            return checkIdModified();
723        case FL_LOG_LIGHT_ID_PERSON_ID:
724            return checkPersonIdModified();
725        case FL_LOG_LIGHT_ID_NAME:
726            return checkNameModified();
727        case FL_LOG_LIGHT_ID_PAPERS_TYPE:
728            return checkPapersTypeModified();
729        case FL_LOG_LIGHT_ID_PAPERS_NUM:
730            return checkPapersNumModified();
731        case FL_LOG_LIGHT_ID_VERIFY_TIME:
732            return checkVerifyTimeModified();
733        case FL_LOG_LIGHT_ID_DIRECTION:
734            return checkDirectionModified();
735        default:
736            return false;
737        }        
738    }
739
740    @Override
741    public boolean isInitialized(int columnID){
742        switch(columnID) {
743        case FL_LOG_LIGHT_ID_ID:
744            return checkIdInitialized();
745        case FL_LOG_LIGHT_ID_PERSON_ID:
746            return checkPersonIdInitialized();
747        case FL_LOG_LIGHT_ID_NAME:
748            return checkNameInitialized();
749        case FL_LOG_LIGHT_ID_PAPERS_TYPE:
750            return checkPapersTypeInitialized();
751        case FL_LOG_LIGHT_ID_PAPERS_NUM:
752            return checkPapersNumInitialized();
753        case FL_LOG_LIGHT_ID_VERIFY_TIME:
754            return checkVerifyTimeInitialized();
755        case FL_LOG_LIGHT_ID_DIRECTION:
756            return checkDirectionInitialized();
757        default:
758            return false;
759        }
760    }
761    
762    @Override
763    public boolean isModified(String column){        
764        return isModified(columnIDOf(column));
765    }
766
767    @Override
768    public boolean isInitialized(String column){
769        return isInitialized(columnIDOf(column));
770    }
771    
772    @Override
773    public void resetIsModified()
774    {
775        checkMutable();
776        modified = 0;
777    }
778
779    @Override
780    public void resetPrimaryKeysModified()
781    {
782        // columns is null or empty;
783    }
784    /**
785     * Resets columns modification status except primary keys to 'not modified'.
786     */
787    public void resetModifiedExceptPrimaryKeys()
788    {
789        modified &= (~(FL_LOG_LIGHT_ID_ID_MASK |
790            FL_LOG_LIGHT_ID_PERSON_ID_MASK |
791            FL_LOG_LIGHT_ID_NAME_MASK |
792            FL_LOG_LIGHT_ID_PAPERS_TYPE_MASK |
793            FL_LOG_LIGHT_ID_PAPERS_NUM_MASK |
794            FL_LOG_LIGHT_ID_VERIFY_TIME_MASK |
795            FL_LOG_LIGHT_ID_DIRECTION_MASK));
796    }
797    /**
798     * Resets the object initialization status to 'not initialized'.
799     */
800    private void resetInitialized()
801    {
802        initialized = 0;
803    }
804    /** reset all fields to initial value, equal to a new bean */
805    public void reset(){
806        checkMutable();
807        /* DEFAULT:'0'*/
808        this.id = new Integer(0);
809        /* DEFAULT:'0'*/
810        this.personId = new Integer(0);
811        this.name = null;
812        this.papersType = null;
813        this.papersNum = null;
814        /* DEFAULT:'0000-00-00 00:00:00'*/
815        this.verifyTime = null;
816        this.direction = null;
817        this.isNew = true;
818        this.modified = 0;
819        this.initialized = (FL_LOG_LIGHT_ID_ID_MASK | FL_LOG_LIGHT_ID_PERSON_ID_MASK);
820    }
821    @Override
822    public boolean equals(Object object)
823    {
824        if (!(object instanceof LogLightBean)) {
825            return false;
826        }
827
828        LogLightBean obj = (LogLightBean) object;
829        return new EqualsBuilder()
830            .append(getId(), obj.getId())
831            .append(getPersonId(), obj.getPersonId())
832            .append(getName(), obj.getName())
833            .append(getPapersType(), obj.getPapersType())
834            .append(getPapersNum(), obj.getPapersNum())
835            .append(getVerifyTime(), obj.getVerifyTime())
836            .append(getDirection(), obj.getDirection())
837            .isEquals();
838    }
839
840    @Override
841    public int hashCode()
842    {
843        return new HashCodeBuilder(-82280557, -700257973)
844            .append(getId())
845            .append(getPersonId())
846            .append(getName())
847            .append(getPapersType())
848            .append(getPapersNum())
849            .append(getVerifyTime())
850            .append(getDirection())
851            .toHashCode();
852    }
853
854    @Override
855    public String toString() {
856        return toString(true,false);
857    }
858    /**
859     * cast byte array to HEX string
860     * 
861     * @param input
862     * @return {@code null} if {@code input} is null
863     */
864    private static final String toHex(byte[] input) {
865        if (null == input){
866            return null;
867        }
868        StringBuffer sb = new StringBuffer(input.length * 2);
869        for (int i = 0; i < input.length; i++) {
870            sb.append(Character.forDigit((input[i] & 240) >> 4, 16));
871            sb.append(Character.forDigit(input[i] & 15, 16));
872        }
873        return sb.toString();
874    }
875    protected static final StringBuilder append(StringBuilder buffer,boolean full,byte[] value){
876        if(full || null == value){
877            buffer.append(toHex(value));
878        }else{
879            buffer.append(value.length).append(" bytes");
880        }
881        return buffer;
882    }
883    private static int stringLimit = 64;
884    private static final int MINIMUM_LIMIT = 16;
885    protected static final StringBuilder append(StringBuilder buffer,boolean full,String value){
886        if(full || null == value || value.length() <= stringLimit){
887            buffer.append(value);
888        }else{
889            buffer.append(value.substring(0,stringLimit - 8)).append(" ...").append(value.substring(stringLimit-4,stringLimit));
890        }
891        return buffer;
892    }
893    protected static final <T>StringBuilder append(StringBuilder buffer,boolean full,T value){
894        return buffer.append(value);
895    }
896    public static final void setStringLimit(int limit){
897        if(limit < MINIMUM_LIMIT){
898            throw new IllegalArgumentException(String.format("INVALID limit %d,minimum value %d",limit,MINIMUM_LIMIT));
899        }
900        stringLimit = limit;
901    }
902    @Override
903    public String toString(boolean notNull, boolean fullIfStringOrBytes) {
904        // only output initialized field
905        StringBuilder builder = new StringBuilder(this.getClass().getName()).append("@").append(Integer.toHexString(this.hashCode())).append("[");
906        int count = 0;        
907        if(checkIdInitialized()){
908            if(!notNull || null != getId()){
909                if(count++ >0){
910                    builder.append(",");
911                }
912                builder.append("id=");
913                append(builder,fullIfStringOrBytes,getId());
914            }
915        }
916        if(checkPersonIdInitialized()){
917            if(!notNull || null != getPersonId()){
918                if(count++ >0){
919                    builder.append(",");
920                }
921                builder.append("person_id=");
922                append(builder,fullIfStringOrBytes,getPersonId());
923            }
924        }
925        if(checkNameInitialized()){
926            if(!notNull || null != getName()){
927                if(count++ >0){
928                    builder.append(",");
929                }
930                builder.append("name=");
931                append(builder,fullIfStringOrBytes,getName());
932            }
933        }
934        if(checkPapersTypeInitialized()){
935            if(!notNull || null != getPapersType()){
936                if(count++ >0){
937                    builder.append(",");
938                }
939                builder.append("papers_type=");
940                append(builder,fullIfStringOrBytes,getPapersType());
941            }
942        }
943        if(checkPapersNumInitialized()){
944            if(!notNull || null != getPapersNum()){
945                if(count++ >0){
946                    builder.append(",");
947                }
948                builder.append("papers_num=");
949                append(builder,fullIfStringOrBytes,getPapersNum());
950            }
951        }
952        if(checkVerifyTimeInitialized()){
953            if(!notNull || null != getVerifyTime()){
954                if(count++ >0){
955                    builder.append(",");
956                }
957                builder.append("verify_time=");
958                append(builder,fullIfStringOrBytes,getVerifyTime());
959            }
960        }
961        if(checkDirectionInitialized()){
962            if(!notNull || null != getDirection()){
963                if(count++ >0){
964                    builder.append(",");
965                }
966                builder.append("direction=");
967                append(builder,fullIfStringOrBytes,getDirection());
968            }
969        }
970        builder.append("]");
971        return builder.toString();
972    }
973    @Override
974    public int compareTo(LogLightBean object){
975        return new CompareToBuilder()
976            .append(getId(), object.getId())
977            .append(getPersonId(), object.getPersonId())
978            .append(getName(), object.getName())
979            .append(getPapersType(), object.getPapersType())
980            .append(getPapersNum(), object.getPapersNum())
981            .append(getVerifyTime(), object.getVerifyTime())
982            .append(getDirection(), object.getDirection())
983            .toComparison();
984    }
985    @Override
986    public LogLightBean clone(){
987        try {
988            return (LogLightBean) super.clone();
989        } catch (CloneNotSupportedException e) {
990            throw new RuntimeException(e);
991        }
992    }
993    /**
994     * Make {@code this} to a NULL bean<br>
995     * set all fields to null, {@link #modified} and {@link #initialized} be set to 0
996     * @return {@code this} bean
997     * @author guyadong
998     */
999    public LogLightBean asNULL()
1000    {   
1001        checkMutable();
1002        
1003        setId((Integer)null);
1004        setPersonId((Integer)null);
1005        setName((String)null);
1006        setPapersType((Integer)null);
1007        setPapersNum((String)null);
1008        setVerifyTime((java.util.Date)null);
1009        setDirection((Integer)null);
1010        isNew(true);
1011        resetInitialized();
1012        resetIsModified();
1013        return this;
1014    }
1015    /**
1016     * check whether this bean is a NULL bean 
1017     * @return {@code true} if {@link #initialized} be set to zero
1018     * @see #asNULL()
1019     */
1020    public boolean checkNULL(){
1021        return 0 == getInitialized();
1022    }
1023    /** 
1024     * @param source source list
1025     * @return {@code source} replace {@code null} element with null instance({@link #NULL})
1026     */
1027    public static final List<LogLightBean> replaceNull(List<LogLightBean> source){
1028        if(null != source){
1029            for(int i = 0,endIndex = source.size();i<endIndex;++i){
1030                if(null == source.get(i)){
1031                    source.set(i, NULL);
1032                }
1033            }
1034        }
1035        return source;
1036    }
1037    /** 
1038     * @param source input list
1039     * @return replace null instance element with {@code null}
1040     * @see #checkNULL()
1041     */
1042    public static final List<LogLightBean> replaceNullInstance(List<LogLightBean> source){
1043        if(null != source){
1044            for(int i = 0,endIndex = source.size();i<endIndex;++i){
1045                if(source.get(i).checkNULL()){
1046                    source.set(i, null);
1047                }
1048            }
1049        }
1050        return source;
1051    }
1052    @Override
1053    public LogLightBean copy(LogLightBean bean)
1054    {
1055        return copy(bean,new int[]{});
1056    }
1057    @Override
1058    public LogLightBean copy(LogLightBean bean, int... fieldList)
1059    {
1060        if (null == fieldList || 0 == fieldList.length){
1061            fieldList = new int[]{0,1,2,3,4,5,6};
1062        }
1063        for (int i = 0; i < fieldList.length; ++i) {
1064            if( bean.isInitialized(fieldList[i]) && !Objects.deepEquals(bean.getValue(fieldList[i]), getValue(fieldList[i]))){
1065                setValue(fieldList[i], bean.getValue(fieldList[i]));
1066            }
1067        }
1068        return this;
1069    }
1070        
1071    @Override
1072    public LogLightBean copy(LogLightBean bean, String... fieldList)
1073    {
1074        if (null == fieldList || 0 == fieldList.length){
1075            copy(bean,(int[])null);
1076        }else{
1077            int field;
1078            for (int i = 0; i < fieldList.length; i++) {
1079                field = columnIDOf(fieldList[i].trim());
1080                if(bean.isInitialized(field) && !Objects.deepEquals(bean.getValue(field), getValue(field))){
1081                    setValue(field, bean.getValue(field));
1082                }
1083            }
1084        }
1085        return this;
1086    }
1087
1088    @SuppressWarnings("unchecked")
1089    @Override
1090    public <T>T getValue(int columnID)
1091    {
1092        switch( columnID ){
1093        case FL_LOG_LIGHT_ID_ID: 
1094            return (T)getId();        
1095        case FL_LOG_LIGHT_ID_PERSON_ID: 
1096            return (T)getPersonId();        
1097        case FL_LOG_LIGHT_ID_NAME: 
1098            return (T)getName();        
1099        case FL_LOG_LIGHT_ID_PAPERS_TYPE: 
1100            return (T)getPapersType();        
1101        case FL_LOG_LIGHT_ID_PAPERS_NUM: 
1102            return (T)getPapersNum();        
1103        case FL_LOG_LIGHT_ID_VERIFY_TIME: 
1104            return (T)getVerifyTime();        
1105        case FL_LOG_LIGHT_ID_DIRECTION: 
1106            return (T)getDirection();        
1107        default:
1108            return null;
1109        }
1110    }
1111
1112    @Override
1113    public <T> void setValue(int columnID,T value)
1114    {
1115        switch( columnID ) {
1116        case FL_LOG_LIGHT_ID_ID:
1117            setId((Integer)value);
1118            break;
1119        case FL_LOG_LIGHT_ID_PERSON_ID:
1120            setPersonId((Integer)value);
1121            break;
1122        case FL_LOG_LIGHT_ID_NAME:
1123            setName((String)value);
1124            break;
1125        case FL_LOG_LIGHT_ID_PAPERS_TYPE:
1126            setPapersType((Integer)value);
1127            break;
1128        case FL_LOG_LIGHT_ID_PAPERS_NUM:
1129            setPapersNum((String)value);
1130            break;
1131        case FL_LOG_LIGHT_ID_VERIFY_TIME:
1132            setVerifyTime((java.util.Date)value);
1133            break;
1134        case FL_LOG_LIGHT_ID_DIRECTION:
1135            setDirection((Integer)value);
1136            break;
1137        default:
1138            break;
1139        }
1140    }
1141    
1142    @Override
1143    public <T> T getValue(String column)
1144    {
1145        return getValue(columnIDOf(column));
1146    }
1147
1148    @Override
1149    public <T> void setValue(String column,T value)
1150    {
1151        setValue(columnIDOf(column),value);
1152    }
1153    
1154    /**
1155     * @param column column name
1156     * @return column id for the given field name or negative if {@code column} is invalid name 
1157     */
1158    public static int columnIDOf(String column){
1159        int index = FL_LOG_LIGHT_FIELDS_LIST.indexOf(column);
1160        return  index < 0 
1161            ? FL_LOG_LIGHT_JAVA_FIELDS_LIST.indexOf(column)
1162            : index;
1163    }
1164    
1165    public static String columnNameOf(int columnId){
1166        try{
1167            return FL_LOG_LIGHT_FIELDS_LIST.get(columnId);
1168        } catch(IndexOutOfBoundsException e){
1169            return null;
1170        }
1171    }
1172    
1173    public static Class<?> typeOf(int columnId){
1174        try{
1175            return FL_LOG_LIGHT_FIELD_TYPES[columnId];
1176        } catch(IndexOutOfBoundsException e){
1177            return null;
1178        }
1179    }
1180    
1181    public static final Builder builder(){
1182        return new Builder().reset();
1183    }
1184    /** 
1185     * a builder for LogLightBean,the template instance is thread local variable
1186     * a instance of Builder can be reused.
1187     */
1188    public static final class Builder{
1189        /** LogLightBean instance used for template to create new LogLightBean instance. */
1190        static final ThreadLocal<LogLightBean> TEMPLATE = new ThreadLocal<LogLightBean>(){
1191            @Override
1192            protected LogLightBean initialValue() {
1193                return new LogLightBean();
1194            }};
1195        private Builder() {}
1196        /** 
1197         * reset the bean as template 
1198         * @see LogLightBean#reset()
1199         */
1200        public Builder reset(){
1201            TEMPLATE.get().reset();
1202            return this;
1203        }
1204        /** set a bean as template,must not be {@code null} */
1205        public Builder template(LogLightBean bean){
1206            if(null == bean){
1207                throw new NullPointerException();
1208            }
1209            TEMPLATE.set(bean);
1210            return this;
1211        }
1212        /** return a clone instance of {@link #TEMPLATE}*/
1213        public LogLightBean build(){
1214            return TEMPLATE.get().clone();
1215        }
1216        /** 
1217         * fill the field : fl_log_light.id
1218         * @param id 日志id
1219         * @see LogLightBean#getId()
1220         * @see LogLightBean#setId(Integer)
1221         */
1222        public Builder id(Integer id){
1223            TEMPLATE.get().setId(id);
1224            return this;
1225        }
1226        /** 
1227         * fill the field : fl_log_light.person_id
1228         * @param personId 用户id
1229         * @see LogLightBean#getPersonId()
1230         * @see LogLightBean#setPersonId(Integer)
1231         */
1232        public Builder personId(Integer personId){
1233            TEMPLATE.get().setPersonId(personId);
1234            return this;
1235        }
1236        /** 
1237         * fill the field : fl_log_light.name
1238         * @param name 姓名
1239         * @see LogLightBean#getName()
1240         * @see LogLightBean#setName(String)
1241         */
1242        public Builder name(String name){
1243            TEMPLATE.get().setName(name);
1244            return this;
1245        }
1246        /** 
1247         * fill the field : fl_log_light.papers_type
1248         * @param papersType 证件类型,0:未知,1:身份证,2:护照,3:台胞证,4:港澳通行证,5:军官证,6:外国人居留证,7:员工卡,8:其他
1249         * @see LogLightBean#getPapersType()
1250         * @see LogLightBean#setPapersType(Integer)
1251         */
1252        public Builder papersType(Integer papersType){
1253            TEMPLATE.get().setPapersType(papersType);
1254            return this;
1255        }
1256        /** 
1257         * fill the field : fl_log_light.papers_num
1258         * @param papersNum 证件号码
1259         * @see LogLightBean#getPapersNum()
1260         * @see LogLightBean#setPapersNum(String)
1261         */
1262        public Builder papersNum(String papersNum){
1263            TEMPLATE.get().setPapersNum(papersNum);
1264            return this;
1265        }
1266        /** 
1267         * fill the field : fl_log_light.verify_time
1268         * @param verifyTime 验证时间(可能由前端设备提供时间)
1269         * @see LogLightBean#getVerifyTime()
1270         * @see LogLightBean#setVerifyTime(java.util.Date)
1271         */
1272        public Builder verifyTime(java.util.Date verifyTime){
1273            TEMPLATE.get().setVerifyTime(verifyTime);
1274            return this;
1275        }
1276        /** 
1277         * fill the field : fl_log_light.direction
1278         * @param direction 通行方向,NULL,0:入口,1:出口,默认0
1279         * @see LogLightBean#getDirection()
1280         * @see LogLightBean#setDirection(Integer)
1281         */
1282        public Builder direction(Integer direction){
1283            TEMPLATE.get().setDirection(direction);
1284            return this;
1285        }
1286    }
1287}