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 * PermitBean is a mapping of fl_permit Table.
020 * <br>Meta Data Information (in progress):
021 * <ul>
022 *    <li>comments: 通行权限关联表 </li>
023 * </ul>
024 * @author guyadong
025*/
026@ThriftStruct
027@ApiModel(description="通行权限关联表")
028public final class PermitBean
029    implements Serializable,BaseBean<PermitBean>,Comparable<PermitBean>,Constant,Cloneable
030{
031    private static final long serialVersionUID = 1996786947221016855L;
032    /** NULL {@link PermitBean} bean , IMMUTABLE instance */
033    public static final PermitBean NULL = new PermitBean().asNULL().asImmutable();
034    /** comments:外键,设备组id */
035    @ApiModelProperty(value = "外键,设备组id" ,required=true ,dataType="Integer")
036    private Integer deviceGroupId;
037
038    /** comments:外键,人员组id */
039    @ApiModelProperty(value = "外键,人员组id" ,required=true ,dataType="Integer")
040    private Integer personGroupId;
041
042    /** comments:允许通行时间表,为null或空为7x24小时工作,格式为JSON,参见开发手册 */
043    @ApiModelProperty(value = "允许通行时间表,为null或空为7x24小时工作,格式为JSON,参见开发手册"  ,dataType="String")
044    private String schedule;
045
046    /** comments:通行次/天数限制定义,为null或空不限制,JSON格式字符串,参见开发手册 */
047    @ApiModelProperty(value = "通行次/天数限制定义,为null或空不限制,JSON格式字符串,参见开发手册"  ,dataType="String")
048    private String passLimit;
049
050    /** comments:备注 */
051    @ApiModelProperty(value = "备注"  ,dataType="String")
052    private String remark;
053
054    /** comments:应用项目自定义二进制扩展字段(最大64KB) */
055    @ApiModelProperty(value = "应用项目自定义二进制扩展字段(最大64KB)"  ,dataType="ByteBuffer")
056    private java.nio.ByteBuffer extBin;
057
058    /** comments:应用项目自定义文本扩展字段(最大64KB) */
059    @ApiModelProperty(value = "应用项目自定义文本扩展字段(最大64KB)"  ,dataType="String")
060    private String extTxt;
061
062    @ApiModelProperty(value = "create_time"  ,dataType="Date")
063    private java.util.Date createTime;
064
065    /** flag whether {@code this} can be modified */
066    private Boolean immutable;
067    /** columns modified flag */
068    @ApiModelProperty(value="columns modified flag",dataType="int",required=true)
069    private int modified;
070    /** columns initialized flag */
071    @ApiModelProperty(value="columns initialized flag",dataType="int",required=true)
072    private int initialized;
073    /** new record flag  */
074    @ApiModelProperty(value="new record flag",dataType="boolean",required=true)
075    private boolean isNew;        
076    /** 
077     * set immutable status
078     * @return {@code this} 
079     */
080    private PermitBean immutable(Boolean immutable) {
081        this.immutable = immutable;
082        return this;
083    }
084    /** 
085     * set {@code this} as immutable object
086     * @return {@code this} 
087     */
088    public PermitBean asImmutable() {
089        return immutable(Boolean.TRUE);
090    }
091    /**
092     * @return {@code true} if {@code this} is a mutable object  
093     */
094    public boolean mutable(){
095        return !Boolean.TRUE.equals(this.immutable);
096    }
097    /**
098     * @return {@code this}
099     * @throws IllegalStateException if {@code this} is a immutable object 
100     */
101    private PermitBean checkMutable(){
102        if(!mutable()){
103            throw new IllegalStateException("this is a immutable object");
104        }
105        return this;
106    }
107    /**
108     * @return return a new mutable copy of this object.
109     */
110    public PermitBean cloneMutable(){
111        return clone().immutable(null);
112    }
113    @ThriftField(value=1,name="_new",requiredness=Requiredness.REQUIRED)
114    @Override
115    public boolean isNew()
116    {
117        return this.isNew;
118    }
119
120
121    @Override
122    public void isNew(boolean isNew)
123    {
124        this.isNew = isNew;
125    }
126    /**
127     * Specifies to the object if it has been set as new.
128     *
129     * @param isNew the boolean value to be assigned to the isNew field
130     */
131    @ThriftField()
132    public void setNew(boolean isNew)
133    {
134        this.isNew = isNew;
135    }
136    /**
137     * @return the modified status of columns
138     */
139    @ThriftField(value=2,requiredness=Requiredness.REQUIRED)
140    public int getModified(){
141        return modified;
142    }
143
144    /**
145     * @param modified the modified status bit to be assigned to {@link #modified}
146     */
147    @ThriftField()
148    public void setModified(int modified){
149        this.modified = modified;
150    }
151    /**
152     * @return the initialized status of columns
153     */
154    @ThriftField(value=3,requiredness=Requiredness.REQUIRED)
155    public int getInitialized(){
156        return initialized;
157    }
158
159    /**
160     * @param initialized the initialized status bit to be assigned to {@link #initialized}
161     */
162    @ThriftField()
163    public void setInitialized(int initialized){
164        this.initialized = initialized;
165    }
166    protected static final <T extends Comparable<T>>boolean equals(T a, T b) {
167        return a == b || (a != null && 0==a.compareTo(b));
168    }
169    public PermitBean(){
170        super();
171        reset();
172    }
173    /**
174     * construct a new instance filled with primary keys
175     * @param deviceGroupId PK# 1 
176     @param personGroupId PK# 2 
177     */
178    public PermitBean(Integer deviceGroupId,Integer personGroupId){
179        this();
180        setDeviceGroupId(deviceGroupId);
181        setPersonGroupId(personGroupId);
182    }
183    /**
184     * Getter method for {@link #deviceGroupId}.<br>
185     * PRIMARY KEY.<br>
186     * Meta Data Information (in progress):
187     * <ul>
188     * <li>full name: fl_permit.device_group_id</li>
189     * <li> foreign key: fl_device_group.id</li>
190     * <li>comments: 外键,设备组id</li>
191     * <li>NOT NULL</li>
192     * <li>column size: 10</li>
193     * <li>JDBC type returned by the driver: Types.INTEGER</li>
194     * </ul>
195     *
196     * @return the value of deviceGroupId
197     */
198    @ThriftField(value=4)
199    public Integer getDeviceGroupId(){
200        return deviceGroupId;
201    }
202    /**
203     * Setter method for {@link #deviceGroupId}.<br>
204     * The new value is set only if equals() says it is different,
205     * or if one of either the new value or the current value is null.
206     * In case the new value is different, it is set and the field is marked as 'modified'.
207     *
208     * @param newVal the new value( NOT NULL) to be assigned to deviceGroupId
209     */
210    public void setDeviceGroupId(Integer newVal)
211    {
212        checkMutable();
213
214        modified |= FL_PERMIT_ID_DEVICE_GROUP_ID_MASK;
215        initialized |= FL_PERMIT_ID_DEVICE_GROUP_ID_MASK;
216
217        if (Objects.equals(newVal, deviceGroupId)) {
218            return;
219        }
220        deviceGroupId = newVal;
221    }
222    /** 
223     * setter for thrift:swift support<br>
224     * without modification for {@link #modified} and {@link #initialized}<br>
225     * <b>NOTE:</b>DO NOT use the method in your code
226     */
227    @ThriftField(name = "deviceGroupId")
228    public void writeDeviceGroupId(Integer newVal){
229        checkMutable();
230        deviceGroupId = newVal;
231    }
232    /**
233     * Setter method for {@link #deviceGroupId}.<br>
234     * Convenient for those who do not want to deal with Objects for primary types.
235     *
236     * @param newVal the new value to be assigned to deviceGroupId
237     */
238    public void setDeviceGroupId(int newVal)
239    {
240        setDeviceGroupId(new Integer(newVal));
241    }
242    /**
243     * Determines if the deviceGroupId has been modified.
244     *
245     * @return true if the field has been modified, false if the field has not been modified
246     */
247    public boolean checkDeviceGroupIdModified()
248    {
249        return 0L !=  (modified & FL_PERMIT_ID_DEVICE_GROUP_ID_MASK);
250    }
251
252    /**
253     * Determines if the deviceGroupId has been initialized.<br>
254     *
255     * It is useful to determine if a field is null on purpose or just because it has not been initialized.
256     *
257     * @return true if the field has been initialized, false otherwise
258     */
259    public boolean checkDeviceGroupIdInitialized()
260    {
261        return 0L !=  (initialized & FL_PERMIT_ID_DEVICE_GROUP_ID_MASK);
262    }
263    /**
264     * Getter method for {@link #personGroupId}.<br>
265     * PRIMARY KEY.<br>
266     * Meta Data Information (in progress):
267     * <ul>
268     * <li>full name: fl_permit.person_group_id</li>
269     * <li> foreign key: fl_person_group.id</li>
270     * <li>comments: 外键,人员组id</li>
271     * <li>NOT NULL</li>
272     * <li>column size: 10</li>
273     * <li>JDBC type returned by the driver: Types.INTEGER</li>
274     * </ul>
275     *
276     * @return the value of personGroupId
277     */
278    @ThriftField(value=5)
279    public Integer getPersonGroupId(){
280        return personGroupId;
281    }
282    /**
283     * Setter method for {@link #personGroupId}.<br>
284     * The new value is set only if equals() says it is different,
285     * or if one of either the new value or the current value is null.
286     * In case the new value is different, it is set and the field is marked as 'modified'.
287     *
288     * @param newVal the new value( NOT NULL) to be assigned to personGroupId
289     */
290    public void setPersonGroupId(Integer newVal)
291    {
292        checkMutable();
293
294        modified |= FL_PERMIT_ID_PERSON_GROUP_ID_MASK;
295        initialized |= FL_PERMIT_ID_PERSON_GROUP_ID_MASK;
296
297        if (Objects.equals(newVal, personGroupId)) {
298            return;
299        }
300        personGroupId = newVal;
301    }
302    /** 
303     * setter for thrift:swift support<br>
304     * without modification for {@link #modified} and {@link #initialized}<br>
305     * <b>NOTE:</b>DO NOT use the method in your code
306     */
307    @ThriftField(name = "personGroupId")
308    public void writePersonGroupId(Integer newVal){
309        checkMutable();
310        personGroupId = newVal;
311    }
312    /**
313     * Setter method for {@link #personGroupId}.<br>
314     * Convenient for those who do not want to deal with Objects for primary types.
315     *
316     * @param newVal the new value to be assigned to personGroupId
317     */
318    public void setPersonGroupId(int newVal)
319    {
320        setPersonGroupId(new Integer(newVal));
321    }
322    /**
323     * Determines if the personGroupId has been modified.
324     *
325     * @return true if the field has been modified, false if the field has not been modified
326     */
327    public boolean checkPersonGroupIdModified()
328    {
329        return 0L !=  (modified & FL_PERMIT_ID_PERSON_GROUP_ID_MASK);
330    }
331
332    /**
333     * Determines if the personGroupId has been initialized.<br>
334     *
335     * It is useful to determine if a field is null on purpose or just because it has not been initialized.
336     *
337     * @return true if the field has been initialized, false otherwise
338     */
339    public boolean checkPersonGroupIdInitialized()
340    {
341        return 0L !=  (initialized & FL_PERMIT_ID_PERSON_GROUP_ID_MASK);
342    }
343    /**
344     * Getter method for {@link #schedule}.<br>
345     * Meta Data Information (in progress):
346     * <ul>
347     * <li>full name: fl_permit.schedule</li>
348     * <li>comments: 允许通行时间表,为null或空为7x24小时工作,格式为JSON,参见开发手册</li>
349     * <li>column size: 4096</li>
350     * <li>JDBC type returned by the driver: Types.VARCHAR</li>
351     * </ul>
352     *
353     * @return the value of schedule
354     */
355    @ThriftField(value=6)
356    public String getSchedule(){
357        return schedule;
358    }
359    /**
360     * Setter method for {@link #schedule}.<br>
361     * The new value is set only if equals() says it is different,
362     * or if one of either the new value or the current value is null.
363     * In case the new value is different, it is set and the field is marked as 'modified'.
364     *
365     * @param newVal the new value to be assigned to schedule
366     */
367    public void setSchedule(String newVal)
368    {
369        checkMutable();
370
371        modified |= FL_PERMIT_ID_SCHEDULE_MASK;
372        initialized |= FL_PERMIT_ID_SCHEDULE_MASK;
373
374        if (Objects.equals(newVal, schedule)) {
375            return;
376        }
377        schedule = newVal;
378    }
379    /** 
380     * setter for thrift:swift support<br>
381     * without modification for {@link #modified} and {@link #initialized}<br>
382     * <b>NOTE:</b>DO NOT use the method in your code
383     */
384    @ThriftField(name = "schedule")
385    public void writeSchedule(String newVal){
386        checkMutable();
387        schedule = newVal;
388    }
389    /**
390     * Determines if the schedule has been modified.
391     *
392     * @return true if the field has been modified, false if the field has not been modified
393     */
394    public boolean checkScheduleModified()
395    {
396        return 0L !=  (modified & FL_PERMIT_ID_SCHEDULE_MASK);
397    }
398
399    /**
400     * Determines if the schedule has been initialized.<br>
401     *
402     * It is useful to determine if a field is null on purpose or just because it has not been initialized.
403     *
404     * @return true if the field has been initialized, false otherwise
405     */
406    public boolean checkScheduleInitialized()
407    {
408        return 0L !=  (initialized & FL_PERMIT_ID_SCHEDULE_MASK);
409    }
410    /**
411     * Getter method for {@link #passLimit}.<br>
412     * Meta Data Information (in progress):
413     * <ul>
414     * <li>full name: fl_permit.pass_limit</li>
415     * <li>comments: 通行次/天数限制定义,为null或空不限制,JSON格式字符串,参见开发手册</li>
416     * <li>column size: 512</li>
417     * <li>JDBC type returned by the driver: Types.VARCHAR</li>
418     * </ul>
419     *
420     * @return the value of passLimit
421     */
422    @ThriftField(value=7)
423    public String getPassLimit(){
424        return passLimit;
425    }
426    /**
427     * Setter method for {@link #passLimit}.<br>
428     * The new value is set only if equals() says it is different,
429     * or if one of either the new value or the current value is null.
430     * In case the new value is different, it is set and the field is marked as 'modified'.
431     *
432     * @param newVal the new value to be assigned to passLimit
433     */
434    public void setPassLimit(String newVal)
435    {
436        checkMutable();
437
438        modified |= FL_PERMIT_ID_PASS_LIMIT_MASK;
439        initialized |= FL_PERMIT_ID_PASS_LIMIT_MASK;
440
441        if (Objects.equals(newVal, passLimit)) {
442            return;
443        }
444        passLimit = newVal;
445    }
446    /** 
447     * setter for thrift:swift support<br>
448     * without modification for {@link #modified} and {@link #initialized}<br>
449     * <b>NOTE:</b>DO NOT use the method in your code
450     */
451    @ThriftField(name = "passLimit")
452    public void writePassLimit(String newVal){
453        checkMutable();
454        passLimit = newVal;
455    }
456    /**
457     * Determines if the passLimit has been modified.
458     *
459     * @return true if the field has been modified, false if the field has not been modified
460     */
461    public boolean checkPassLimitModified()
462    {
463        return 0L !=  (modified & FL_PERMIT_ID_PASS_LIMIT_MASK);
464    }
465
466    /**
467     * Determines if the passLimit has been initialized.<br>
468     *
469     * It is useful to determine if a field is null on purpose or just because it has not been initialized.
470     *
471     * @return true if the field has been initialized, false otherwise
472     */
473    public boolean checkPassLimitInitialized()
474    {
475        return 0L !=  (initialized & FL_PERMIT_ID_PASS_LIMIT_MASK);
476    }
477    /**
478     * Getter method for {@link #remark}.<br>
479     * Meta Data Information (in progress):
480     * <ul>
481     * <li>full name: fl_permit.remark</li>
482     * <li>comments: 备注</li>
483     * <li>column size: 256</li>
484     * <li>JDBC type returned by the driver: Types.VARCHAR</li>
485     * </ul>
486     *
487     * @return the value of remark
488     */
489    @ThriftField(value=8)
490    public String getRemark(){
491        return remark;
492    }
493    /**
494     * Setter method for {@link #remark}.<br>
495     * The new value is set only if equals() says it is different,
496     * or if one of either the new value or the current value is null.
497     * In case the new value is different, it is set and the field is marked as 'modified'.
498     *
499     * @param newVal the new value to be assigned to remark
500     */
501    public void setRemark(String newVal)
502    {
503        checkMutable();
504
505        modified |= FL_PERMIT_ID_REMARK_MASK;
506        initialized |= FL_PERMIT_ID_REMARK_MASK;
507
508        if (Objects.equals(newVal, remark)) {
509            return;
510        }
511        remark = newVal;
512    }
513    /** 
514     * setter for thrift:swift support<br>
515     * without modification for {@link #modified} and {@link #initialized}<br>
516     * <b>NOTE:</b>DO NOT use the method in your code
517     */
518    @ThriftField(name = "remark")
519    public void writeRemark(String newVal){
520        checkMutable();
521        remark = newVal;
522    }
523    /**
524     * Determines if the remark has been modified.
525     *
526     * @return true if the field has been modified, false if the field has not been modified
527     */
528    public boolean checkRemarkModified()
529    {
530        return 0L !=  (modified & FL_PERMIT_ID_REMARK_MASK);
531    }
532
533    /**
534     * Determines if the remark has been initialized.<br>
535     *
536     * It is useful to determine if a field is null on purpose or just because it has not been initialized.
537     *
538     * @return true if the field has been initialized, false otherwise
539     */
540    public boolean checkRemarkInitialized()
541    {
542        return 0L !=  (initialized & FL_PERMIT_ID_REMARK_MASK);
543    }
544    /**
545     * Getter method for {@link #extBin}.<br>
546     * Meta Data Information (in progress):
547     * <ul>
548     * <li>full name: fl_permit.ext_bin</li>
549     * <li>comments: 应用项目自定义二进制扩展字段(最大64KB)</li>
550     * <li>column size: 65535</li>
551     * <li>JDBC type returned by the driver: Types.LONGVARBINARY</li>
552     * </ul>
553     *
554     * @return the value of extBin
555     */
556    @ThriftField(value=9)
557    public java.nio.ByteBuffer getExtBin(){
558        return extBin;
559    }
560    /**
561     * Setter method for {@link #extBin}.<br>
562     * The new value is set only if equals() says it is different,
563     * or if one of either the new value or the current value is null.
564     * In case the new value is different, it is set and the field is marked as 'modified'.
565     *
566     * @param newVal the new value to be assigned to extBin
567     */
568    public void setExtBin(java.nio.ByteBuffer newVal)
569    {
570        checkMutable();
571
572        modified |= FL_PERMIT_ID_EXT_BIN_MASK;
573        initialized |= FL_PERMIT_ID_EXT_BIN_MASK;
574
575        if (Objects.equals(newVal, extBin)) {
576            return;
577        }
578        extBin = newVal;
579    }
580    /** 
581     * setter for thrift:swift support<br>
582     * without modification for {@link #modified} and {@link #initialized}<br>
583     * <b>NOTE:</b>DO NOT use the method in your code
584     */
585    @ThriftField(name = "extBin")
586    public void writeExtBin(java.nio.ByteBuffer newVal){
587        checkMutable();
588        extBin = newVal;
589    }
590    /**
591     * Determines if the extBin has been modified.
592     *
593     * @return true if the field has been modified, false if the field has not been modified
594     */
595    public boolean checkExtBinModified()
596    {
597        return 0L !=  (modified & FL_PERMIT_ID_EXT_BIN_MASK);
598    }
599
600    /**
601     * Determines if the extBin has been initialized.<br>
602     *
603     * It is useful to determine if a field is null on purpose or just because it has not been initialized.
604     *
605     * @return true if the field has been initialized, false otherwise
606     */
607    public boolean checkExtBinInitialized()
608    {
609        return 0L !=  (initialized & FL_PERMIT_ID_EXT_BIN_MASK);
610    }
611    /**
612     * Getter method for {@link #extTxt}.<br>
613     * Meta Data Information (in progress):
614     * <ul>
615     * <li>full name: fl_permit.ext_txt</li>
616     * <li>comments: 应用项目自定义文本扩展字段(最大64KB)</li>
617     * <li>column size: 65535</li>
618     * <li>JDBC type returned by the driver: Types.LONGVARCHAR</li>
619     * </ul>
620     *
621     * @return the value of extTxt
622     */
623    @ThriftField(value=10)
624    public String getExtTxt(){
625        return extTxt;
626    }
627    /**
628     * Setter method for {@link #extTxt}.<br>
629     * The new value is set only if equals() says it is different,
630     * or if one of either the new value or the current value is null.
631     * In case the new value is different, it is set and the field is marked as 'modified'.
632     *
633     * @param newVal the new value to be assigned to extTxt
634     */
635    public void setExtTxt(String newVal)
636    {
637        checkMutable();
638
639        modified |= FL_PERMIT_ID_EXT_TXT_MASK;
640        initialized |= FL_PERMIT_ID_EXT_TXT_MASK;
641
642        if (Objects.equals(newVal, extTxt)) {
643            return;
644        }
645        extTxt = newVal;
646    }
647    /** 
648     * setter for thrift:swift support<br>
649     * without modification for {@link #modified} and {@link #initialized}<br>
650     * <b>NOTE:</b>DO NOT use the method in your code
651     */
652    @ThriftField(name = "extTxt")
653    public void writeExtTxt(String newVal){
654        checkMutable();
655        extTxt = newVal;
656    }
657    /**
658     * Determines if the extTxt has been modified.
659     *
660     * @return true if the field has been modified, false if the field has not been modified
661     */
662    public boolean checkExtTxtModified()
663    {
664        return 0L !=  (modified & FL_PERMIT_ID_EXT_TXT_MASK);
665    }
666
667    /**
668     * Determines if the extTxt has been initialized.<br>
669     *
670     * It is useful to determine if a field is null on purpose or just because it has not been initialized.
671     *
672     * @return true if the field has been initialized, false otherwise
673     */
674    public boolean checkExtTxtInitialized()
675    {
676        return 0L !=  (initialized & FL_PERMIT_ID_EXT_TXT_MASK);
677    }
678    /**
679     * Getter method for {@link #createTime}.<br>
680     * Meta Data Information (in progress):
681     * <ul>
682     * <li>full name: fl_permit.create_time</li>
683     * <li>default value: 'CURRENT_TIMESTAMP'</li>
684     * <li>NOT NULL</li>
685     * <li>column size: 19</li>
686     * <li>JDBC type returned by the driver: Types.TIMESTAMP</li>
687     * </ul>
688     *
689     * @return the value of createTime
690     */
691    public java.util.Date getCreateTime(){
692        return createTime;
693    }
694    /** 
695     * use Long to represent date type for thrift:swift support 
696     * @see #getCreateTime()
697     */
698    @ThriftField(name = "createTime",value = 11)
699    public Long readCreateTime(){
700        return null == createTime ? null:createTime.getTime();
701    }
702    /**
703     * Setter method for {@link #createTime}.<br>
704     * The new value is set only if equals() says it is different,
705     * or if one of either the new value or the current value is null.
706     * In case the new value is different, it is set and the field is marked as 'modified'.
707     *
708     * @param newVal the new value( NOT NULL) to be assigned to createTime
709     */
710    public void setCreateTime(java.util.Date newVal)
711    {
712        checkMutable();
713
714        modified |= FL_PERMIT_ID_CREATE_TIME_MASK;
715        initialized |= FL_PERMIT_ID_CREATE_TIME_MASK;
716
717        if (Objects.equals(newVal, createTime)) {
718            return;
719        }
720        createTime = newVal;
721    }
722    /** 
723     * setter for thrift:swift support<br>
724     * without modification for {@link #modified} and {@link #initialized}<br>
725     * <b>NOTE:</b>DO NOT use the method in your code
726     */
727    @ThriftField(name = "createTime")
728    public void writeCreateTime(Long newVal){
729        checkMutable();
730        createTime = null == newVal?null:new java.util.Date(newVal);
731    }
732    /**
733     * Setter method for {@link #createTime}.<br>
734     * Convenient for those who do not want to deal with Objects for primary types.
735     *
736     * @param newVal the new value to be assigned to createTime
737     */
738    public void setCreateTime(long newVal)
739    {
740        setCreateTime(new java.util.Date(newVal));
741    }
742    /**
743     * Setter method for {@link #createTime}.<br>
744     * @param newVal the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.
745     */
746    public void setCreateTime(Long newVal)
747    {
748        setCreateTime(null == newVal ? null : new java.util.Date(newVal));
749    }
750    /**
751     * Determines if the createTime has been modified.
752     *
753     * @return true if the field has been modified, false if the field has not been modified
754     */
755    public boolean checkCreateTimeModified()
756    {
757        return 0L !=  (modified & FL_PERMIT_ID_CREATE_TIME_MASK);
758    }
759
760    /**
761     * Determines if the createTime has been initialized.<br>
762     *
763     * It is useful to determine if a field is null on purpose or just because it has not been initialized.
764     *
765     * @return true if the field has been initialized, false otherwise
766     */
767    public boolean checkCreateTimeInitialized()
768    {
769        return 0L !=  (initialized & FL_PERMIT_ID_CREATE_TIME_MASK);
770    }
771    //////////////////////////////////////
772    // referenced bean for FOREIGN KEYS
773    //////////////////////////////////////
774    /** 
775     * The referenced {@link DeviceGroupBean} by {@link #deviceGroupId} . <br>
776     * FOREIGN KEY (device_group_id) REFERENCES fl_device_group(id)
777     */
778    @ApiModelProperty(hidden = true)
779    private DeviceGroupBean referencedByDeviceGroupId;
780    /**
781     * Getter method for {@link #referencedByDeviceGroupId}.
782     * @return DeviceGroupBean
783     */
784    public DeviceGroupBean getReferencedByDeviceGroupId() {
785        return this.referencedByDeviceGroupId;
786    }
787    /**
788     * Setter method for {@link #referencedByDeviceGroupId}.
789     * @param reference DeviceGroupBean
790     */
791    public void setReferencedByDeviceGroupId(DeviceGroupBean reference) {
792        this.referencedByDeviceGroupId = reference;
793    }
794    /** 
795     * The referenced {@link PersonGroupBean} by {@link #personGroupId} . <br>
796     * FOREIGN KEY (person_group_id) REFERENCES fl_person_group(id)
797     */
798    @ApiModelProperty(hidden = true)
799    private PersonGroupBean referencedByPersonGroupId;
800    /**
801     * Getter method for {@link #referencedByPersonGroupId}.
802     * @return PersonGroupBean
803     */
804    public PersonGroupBean getReferencedByPersonGroupId() {
805        return this.referencedByPersonGroupId;
806    }
807    /**
808     * Setter method for {@link #referencedByPersonGroupId}.
809     * @param reference PersonGroupBean
810     */
811    public void setReferencedByPersonGroupId(PersonGroupBean reference) {
812        this.referencedByPersonGroupId = reference;
813    }
814
815    @Override
816    public boolean isModified()
817    {
818        return 0 != modified;
819    }
820  
821    @Override
822    public boolean isModified(int columnID){
823        switch ( columnID ){
824        case FL_PERMIT_ID_DEVICE_GROUP_ID:
825            return checkDeviceGroupIdModified();
826        case FL_PERMIT_ID_PERSON_GROUP_ID:
827            return checkPersonGroupIdModified();
828        case FL_PERMIT_ID_SCHEDULE:
829            return checkScheduleModified();
830        case FL_PERMIT_ID_PASS_LIMIT:
831            return checkPassLimitModified();
832        case FL_PERMIT_ID_REMARK:
833            return checkRemarkModified();
834        case FL_PERMIT_ID_EXT_BIN:
835            return checkExtBinModified();
836        case FL_PERMIT_ID_EXT_TXT:
837            return checkExtTxtModified();
838        case FL_PERMIT_ID_CREATE_TIME:
839            return checkCreateTimeModified();
840        default:
841            return false;
842        }        
843    }
844
845    @Override
846    public boolean isInitialized(int columnID){
847        switch(columnID) {
848        case FL_PERMIT_ID_DEVICE_GROUP_ID:
849            return checkDeviceGroupIdInitialized();
850        case FL_PERMIT_ID_PERSON_GROUP_ID:
851            return checkPersonGroupIdInitialized();
852        case FL_PERMIT_ID_SCHEDULE:
853            return checkScheduleInitialized();
854        case FL_PERMIT_ID_PASS_LIMIT:
855            return checkPassLimitInitialized();
856        case FL_PERMIT_ID_REMARK:
857            return checkRemarkInitialized();
858        case FL_PERMIT_ID_EXT_BIN:
859            return checkExtBinInitialized();
860        case FL_PERMIT_ID_EXT_TXT:
861            return checkExtTxtInitialized();
862        case FL_PERMIT_ID_CREATE_TIME:
863            return checkCreateTimeInitialized();
864        default:
865            return false;
866        }
867    }
868    
869    @Override
870    public boolean isModified(String column){        
871        return isModified(columnIDOf(column));
872    }
873
874    @Override
875    public boolean isInitialized(String column){
876        return isInitialized(columnIDOf(column));
877    }
878    
879    @Override
880    public void resetIsModified()
881    {
882        checkMutable();
883        modified = 0;
884    }
885
886    @Override
887    public void resetPrimaryKeysModified()
888    {
889        modified &= (~(FL_PERMIT_ID_DEVICE_GROUP_ID_MASK |
890            FL_PERMIT_ID_PERSON_GROUP_ID_MASK));
891    }
892    /**
893     * Resets columns modification status except primary keys to 'not modified'.
894     */
895    public void resetModifiedExceptPrimaryKeys()
896    {
897        modified &= (~(FL_PERMIT_ID_SCHEDULE_MASK |
898            FL_PERMIT_ID_PASS_LIMIT_MASK |
899            FL_PERMIT_ID_REMARK_MASK |
900            FL_PERMIT_ID_EXT_BIN_MASK |
901            FL_PERMIT_ID_EXT_TXT_MASK |
902            FL_PERMIT_ID_CREATE_TIME_MASK));
903    }
904    /**
905     * Resets the object initialization status to 'not initialized'.
906     */
907    private void resetInitialized()
908    {
909        initialized = 0;
910    }
911    /** reset all fields to initial value, equal to a new bean */
912    public void reset(){
913        checkMutable();
914        this.deviceGroupId = null;
915        this.personGroupId = null;
916        this.schedule = null;
917        this.passLimit = null;
918        this.remark = null;
919        this.extBin = null;
920        this.extTxt = null;
921        /* DEFAULT:'CURRENT_TIMESTAMP'*/
922        this.createTime = null;
923        this.isNew = true;
924        this.modified = 0;
925        this.initialized = 0;
926    }
927    @Override
928    public boolean equals(Object object)
929    {
930        if (!(object instanceof PermitBean)) {
931            return false;
932        }
933
934        PermitBean obj = (PermitBean) object;
935        return new EqualsBuilder()
936            .append(getDeviceGroupId(), obj.getDeviceGroupId())
937            .append(getPersonGroupId(), obj.getPersonGroupId())
938            .append(getSchedule(), obj.getSchedule())
939            .append(getPassLimit(), obj.getPassLimit())
940            .append(getRemark(), obj.getRemark())
941            .append(getExtBin(), obj.getExtBin())
942            .append(getExtTxt(), obj.getExtTxt())
943            .append(getCreateTime(), obj.getCreateTime())
944            .isEquals();
945    }
946
947    @Override
948    public int hashCode()
949    {
950        return new HashCodeBuilder(-82280557, -700257973)
951            .append(getDeviceGroupId())
952            .append(getPersonGroupId())
953            .toHashCode();
954    }
955
956    @Override
957    public String toString() {
958        return toString(true,false);
959    }
960    /**
961     * cast byte array to HEX string
962     * 
963     * @param input
964     * @return {@code null} if {@code input} is null
965     */
966    private static final String toHex(byte[] input) {
967        if (null == input){
968            return null;
969        }
970        StringBuffer sb = new StringBuffer(input.length * 2);
971        for (int i = 0; i < input.length; i++) {
972            sb.append(Character.forDigit((input[i] & 240) >> 4, 16));
973            sb.append(Character.forDigit(input[i] & 15, 16));
974        }
975        return sb.toString();
976    }
977    protected static final StringBuilder append(StringBuilder buffer,boolean full,byte[] value){
978        if(full || null == value){
979            buffer.append(toHex(value));
980        }else{
981            buffer.append(value.length).append(" bytes");
982        }
983        return buffer;
984    }
985    private static int stringLimit = 64;
986    private static final int MINIMUM_LIMIT = 16;
987    protected static final StringBuilder append(StringBuilder buffer,boolean full,String value){
988        if(full || null == value || value.length() <= stringLimit){
989            buffer.append(value);
990        }else{
991            buffer.append(value.substring(0,stringLimit - 8)).append(" ...").append(value.substring(stringLimit-4,stringLimit));
992        }
993        return buffer;
994    }
995    protected static final <T>StringBuilder append(StringBuilder buffer,boolean full,T value){
996        return buffer.append(value);
997    }
998    public static final void setStringLimit(int limit){
999        if(limit < MINIMUM_LIMIT){
1000            throw new IllegalArgumentException(String.format("INVALID limit %d,minimum value %d",limit,MINIMUM_LIMIT));
1001        }
1002        stringLimit = limit;
1003    }
1004    @Override
1005    public String toString(boolean notNull, boolean fullIfStringOrBytes) {
1006        // only output initialized field
1007        StringBuilder builder = new StringBuilder(this.getClass().getName()).append("@").append(Integer.toHexString(this.hashCode())).append("[");
1008        int count = 0;        
1009        if(checkDeviceGroupIdInitialized()){
1010            if(!notNull || null != getDeviceGroupId()){
1011                if(count++ >0){
1012                    builder.append(",");
1013                }
1014                builder.append("device_group_id=");
1015                append(builder,fullIfStringOrBytes,getDeviceGroupId());
1016            }
1017        }
1018        if(checkPersonGroupIdInitialized()){
1019            if(!notNull || null != getPersonGroupId()){
1020                if(count++ >0){
1021                    builder.append(",");
1022                }
1023                builder.append("person_group_id=");
1024                append(builder,fullIfStringOrBytes,getPersonGroupId());
1025            }
1026        }
1027        if(checkScheduleInitialized()){
1028            if(!notNull || null != getSchedule()){
1029                if(count++ >0){
1030                    builder.append(",");
1031                }
1032                builder.append("schedule=");
1033                append(builder,fullIfStringOrBytes,getSchedule());
1034            }
1035        }
1036        if(checkPassLimitInitialized()){
1037            if(!notNull || null != getPassLimit()){
1038                if(count++ >0){
1039                    builder.append(",");
1040                }
1041                builder.append("pass_limit=");
1042                append(builder,fullIfStringOrBytes,getPassLimit());
1043            }
1044        }
1045        if(checkRemarkInitialized()){
1046            if(!notNull || null != getRemark()){
1047                if(count++ >0){
1048                    builder.append(",");
1049                }
1050                builder.append("remark=");
1051                append(builder,fullIfStringOrBytes,getRemark());
1052            }
1053        }
1054        if(checkExtBinInitialized()){
1055            if(!notNull || null != getExtBin()){
1056                if(count++ >0){
1057                    builder.append(",");
1058                }
1059                builder.append("ext_bin=");
1060                append(builder,fullIfStringOrBytes,getExtBin());
1061            }
1062        }
1063        if(checkExtTxtInitialized()){
1064            if(!notNull || null != getExtTxt()){
1065                if(count++ >0){
1066                    builder.append(",");
1067                }
1068                builder.append("ext_txt=");
1069                append(builder,fullIfStringOrBytes,getExtTxt());
1070            }
1071        }
1072        if(checkCreateTimeInitialized()){
1073            if(!notNull || null != getCreateTime()){
1074                if(count++ >0){
1075                    builder.append(",");
1076                }
1077                builder.append("create_time=");
1078                append(builder,fullIfStringOrBytes,getCreateTime());
1079            }
1080        }
1081        builder.append("]");
1082        return builder.toString();
1083    }
1084    @Override
1085    public int compareTo(PermitBean object){
1086        return new CompareToBuilder()
1087            .append(getDeviceGroupId(), object.getDeviceGroupId())
1088            .append(getPersonGroupId(), object.getPersonGroupId())
1089            .append(getSchedule(), object.getSchedule())
1090            .append(getPassLimit(), object.getPassLimit())
1091            .append(getRemark(), object.getRemark())
1092            .append(getExtBin(), object.getExtBin())
1093            .append(getExtTxt(), object.getExtTxt())
1094            .append(getCreateTime(), object.getCreateTime())
1095            .toComparison();
1096    }
1097    @Override
1098    public PermitBean clone(){
1099        try {
1100            return (PermitBean) super.clone();
1101        } catch (CloneNotSupportedException e) {
1102            throw new RuntimeException(e);
1103        }
1104    }
1105    /**
1106     * Make {@code this} to a NULL bean<br>
1107     * set all fields to null, {@link #modified} and {@link #initialized} be set to 0
1108     * @return {@code this} bean
1109     * @author guyadong
1110     */
1111    public PermitBean asNULL()
1112    {   
1113        checkMutable();
1114        
1115        setDeviceGroupId((Integer)null);
1116        setPersonGroupId((Integer)null);
1117        setSchedule((String)null);
1118        setPassLimit((String)null);
1119        setRemark((String)null);
1120        setExtBin((java.nio.ByteBuffer)null);
1121        setExtTxt((String)null);
1122        setCreateTime((java.util.Date)null);
1123        isNew(true);
1124        resetInitialized();
1125        resetIsModified();
1126        return this;
1127    }
1128    /**
1129     * check whether this bean is a NULL bean 
1130     * @return {@code true} if {@link #initialized} be set to zero
1131     * @see #asNULL()
1132     */
1133    public boolean checkNULL(){
1134        return 0 == getInitialized();
1135    }
1136    /** 
1137     * @param source source list
1138     * @return {@code source} replace {@code null} element with null instance({@link #NULL})
1139     */
1140    public static final List<PermitBean> replaceNull(List<PermitBean> source){
1141        if(null != source){
1142            for(int i = 0,endIndex = source.size();i<endIndex;++i){
1143                if(null == source.get(i)){
1144                    source.set(i, NULL);
1145                }
1146            }
1147        }
1148        return source;
1149    }
1150    /** 
1151     * @param source input list
1152     * @return replace null instance element with {@code null}
1153     * @see #checkNULL()
1154     */
1155    public static final List<PermitBean> replaceNullInstance(List<PermitBean> source){
1156        if(null != source){
1157            for(int i = 0,endIndex = source.size();i<endIndex;++i){
1158                if(source.get(i).checkNULL()){
1159                    source.set(i, null);
1160                }
1161            }
1162        }
1163        return source;
1164    }
1165    @Override
1166    public PermitBean copy(PermitBean bean)
1167    {
1168        return copy(bean,new int[]{});
1169    }
1170    @Override
1171    public PermitBean copy(PermitBean bean, int... fieldList)
1172    {
1173        if (null == fieldList || 0 == fieldList.length){
1174            fieldList = new int[]{0,1,2,3,4,5,6,7};
1175        }
1176        for (int i = 0; i < fieldList.length; ++i) {
1177            if( bean.isInitialized(fieldList[i]) && !Objects.deepEquals(bean.getValue(fieldList[i]), getValue(fieldList[i]))){
1178                setValue(fieldList[i], bean.getValue(fieldList[i]));
1179            }
1180        }
1181        return this;
1182    }
1183        
1184    @Override
1185    public PermitBean copy(PermitBean bean, String... fieldList)
1186    {
1187        if (null == fieldList || 0 == fieldList.length){
1188            copy(bean,(int[])null);
1189        }else{
1190            int field;
1191            for (int i = 0; i < fieldList.length; i++) {
1192                field = columnIDOf(fieldList[i].trim());
1193                if(bean.isInitialized(field) && !Objects.deepEquals(bean.getValue(field), getValue(field))){
1194                    setValue(field, bean.getValue(field));
1195                }
1196            }
1197        }
1198        return this;
1199    }
1200
1201    @SuppressWarnings("unchecked")
1202    @Override
1203    public <T>T getValue(int columnID)
1204    {
1205        switch( columnID ){
1206        case FL_PERMIT_ID_DEVICE_GROUP_ID: 
1207            return (T)getDeviceGroupId();        
1208        case FL_PERMIT_ID_PERSON_GROUP_ID: 
1209            return (T)getPersonGroupId();        
1210        case FL_PERMIT_ID_SCHEDULE: 
1211            return (T)getSchedule();        
1212        case FL_PERMIT_ID_PASS_LIMIT: 
1213            return (T)getPassLimit();        
1214        case FL_PERMIT_ID_REMARK: 
1215            return (T)getRemark();        
1216        case FL_PERMIT_ID_EXT_BIN: 
1217            return (T)getExtBin();        
1218        case FL_PERMIT_ID_EXT_TXT: 
1219            return (T)getExtTxt();        
1220        case FL_PERMIT_ID_CREATE_TIME: 
1221            return (T)getCreateTime();        
1222        default:
1223            return null;
1224        }
1225    }
1226
1227    @Override
1228    public <T> void setValue(int columnID,T value)
1229    {
1230        switch( columnID ) {
1231        case FL_PERMIT_ID_DEVICE_GROUP_ID:
1232            setDeviceGroupId((Integer)value);
1233            break;
1234        case FL_PERMIT_ID_PERSON_GROUP_ID:
1235            setPersonGroupId((Integer)value);
1236            break;
1237        case FL_PERMIT_ID_SCHEDULE:
1238            setSchedule((String)value);
1239            break;
1240        case FL_PERMIT_ID_PASS_LIMIT:
1241            setPassLimit((String)value);
1242            break;
1243        case FL_PERMIT_ID_REMARK:
1244            setRemark((String)value);
1245            break;
1246        case FL_PERMIT_ID_EXT_BIN:
1247            setExtBin((java.nio.ByteBuffer)value);
1248            break;
1249        case FL_PERMIT_ID_EXT_TXT:
1250            setExtTxt((String)value);
1251            break;
1252        case FL_PERMIT_ID_CREATE_TIME:
1253            setCreateTime((java.util.Date)value);
1254            break;
1255        default:
1256            break;
1257        }
1258    }
1259    
1260    @Override
1261    public <T> T getValue(String column)
1262    {
1263        return getValue(columnIDOf(column));
1264    }
1265
1266    @Override
1267    public <T> void setValue(String column,T value)
1268    {
1269        setValue(columnIDOf(column),value);
1270    }
1271    
1272    /**
1273     * @param column column name
1274     * @return column id for the given field name or negative if {@code column} is invalid name 
1275     */
1276    public static int columnIDOf(String column){
1277        int index = FL_PERMIT_FIELDS_LIST.indexOf(column);
1278        return  index < 0 
1279            ? FL_PERMIT_JAVA_FIELDS_LIST.indexOf(column)
1280            : index;
1281    }
1282    
1283    public static String columnNameOf(int columnId){
1284        try{
1285            return FL_PERMIT_FIELDS_LIST.get(columnId);
1286        } catch(IndexOutOfBoundsException e){
1287            return null;
1288        }
1289    }
1290    
1291    public static Class<?> typeOf(int columnId){
1292        try{
1293            return FL_PERMIT_FIELD_TYPES[columnId];
1294        } catch(IndexOutOfBoundsException e){
1295            return null;
1296        }
1297    }
1298    
1299    public static final Builder builder(){
1300        return new Builder().reset();
1301    }
1302    /** 
1303     * a builder for PermitBean,the template instance is thread local variable
1304     * a instance of Builder can be reused.
1305     */
1306    public static final class Builder{
1307        /** PermitBean instance used for template to create new PermitBean instance. */
1308        static final ThreadLocal<PermitBean> TEMPLATE = new ThreadLocal<PermitBean>(){
1309            @Override
1310            protected PermitBean initialValue() {
1311                return new PermitBean();
1312            }};
1313        private Builder() {}
1314        /** 
1315         * reset the bean as template 
1316         * @see PermitBean#reset()
1317         */
1318        public Builder reset(){
1319            TEMPLATE.get().reset();
1320            return this;
1321        }
1322        /** set a bean as template,must not be {@code null} */
1323        public Builder template(PermitBean bean){
1324            if(null == bean){
1325                throw new NullPointerException();
1326            }
1327            TEMPLATE.set(bean);
1328            return this;
1329        }
1330        /** return a clone instance of {@link #TEMPLATE}*/
1331        public PermitBean build(){
1332            return TEMPLATE.get().clone();
1333        }
1334        /** 
1335         * fill the field : fl_permit.device_group_id
1336         * @param deviceGroupId 外键,设备组id
1337         * @see PermitBean#getDeviceGroupId()
1338         * @see PermitBean#setDeviceGroupId(Integer)
1339         */
1340        public Builder deviceGroupId(Integer deviceGroupId){
1341            TEMPLATE.get().setDeviceGroupId(deviceGroupId);
1342            return this;
1343        }
1344        /** 
1345         * fill the field : fl_permit.person_group_id
1346         * @param personGroupId 外键,人员组id
1347         * @see PermitBean#getPersonGroupId()
1348         * @see PermitBean#setPersonGroupId(Integer)
1349         */
1350        public Builder personGroupId(Integer personGroupId){
1351            TEMPLATE.get().setPersonGroupId(personGroupId);
1352            return this;
1353        }
1354        /** 
1355         * fill the field : fl_permit.schedule
1356         * @param schedule 允许通行时间表,为null或空为7x24小时工作,格式为JSON,参见开发手册
1357         * @see PermitBean#getSchedule()
1358         * @see PermitBean#setSchedule(String)
1359         */
1360        public Builder schedule(String schedule){
1361            TEMPLATE.get().setSchedule(schedule);
1362            return this;
1363        }
1364        /** 
1365         * fill the field : fl_permit.pass_limit
1366         * @param passLimit 通行次/天数限制定义,为null或空不限制,JSON格式字符串,参见开发手册
1367         * @see PermitBean#getPassLimit()
1368         * @see PermitBean#setPassLimit(String)
1369         */
1370        public Builder passLimit(String passLimit){
1371            TEMPLATE.get().setPassLimit(passLimit);
1372            return this;
1373        }
1374        /** 
1375         * fill the field : fl_permit.remark
1376         * @param remark 备注
1377         * @see PermitBean#getRemark()
1378         * @see PermitBean#setRemark(String)
1379         */
1380        public Builder remark(String remark){
1381            TEMPLATE.get().setRemark(remark);
1382            return this;
1383        }
1384        /** 
1385         * fill the field : fl_permit.ext_bin
1386         * @param extBin 应用项目自定义二进制扩展字段(最大64KB)
1387         * @see PermitBean#getExtBin()
1388         * @see PermitBean#setExtBin(java.nio.ByteBuffer)
1389         */
1390        public Builder extBin(java.nio.ByteBuffer extBin){
1391            TEMPLATE.get().setExtBin(extBin);
1392            return this;
1393        }
1394        /** 
1395         * fill the field : fl_permit.ext_txt
1396         * @param extTxt 应用项目自定义文本扩展字段(最大64KB)
1397         * @see PermitBean#getExtTxt()
1398         * @see PermitBean#setExtTxt(String)
1399         */
1400        public Builder extTxt(String extTxt){
1401            TEMPLATE.get().setExtTxt(extTxt);
1402            return this;
1403        }
1404        /** 
1405         * fill the field : fl_permit.create_time
1406         * @param createTime 
1407         * @see PermitBean#getCreateTime()
1408         * @see PermitBean#setCreateTime(java.util.Date)
1409         */
1410        public Builder createTime(java.util.Date createTime){
1411            TEMPLATE.get().setCreateTime(createTime);
1412            return this;
1413        }
1414    }
1415}