package jp.co.y_net.amm.dao;

import java.io.Serializable;
import java.util.Comparator;


public class Grp extends AppDto implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    /* DBMSと連携するメンバ */
    private Integer grpid;
    private String name;
    private Integer adminusrid;
    private Long createdate;

    
    /* アプリケーションで設定するメンバ */
    // なし
    
    /* 自動生成のアクセサ */
    public Integer getGrpid() {
        return grpid;
    }
    public void setGrpid(Integer grpid) {
        this.grpid = grpid;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Integer getAdminusrid() {
        return adminusrid;
    }
    public void setAdminusrid(Integer adminusrid) {
        this.adminusrid = adminusrid;
    }
    public Long getCreatedate() {
        return createdate;
    }
    public void setCreatedate(Long createdate) {
        this.createdate = createdate;
    }
    /* 自動生成のアクセサ -end */

    /* 型変換のアクセサ */
    /* 型変換のアクセサ - end */

    
    
    /**
     * 作成日時のソートに用いるComparator
     */
    public static class CreatedateComparator implements Comparator<Grp> {
        /** trueに変更すると 申請日時の新しい順 */
        private boolean desc = false; 
        
        public CreatedateComparator(boolean desc) {
            this.desc = desc;
        }
        
        @Override
        public int compare(Grp o1, Grp o2) {
            int reverse = 1;
            if(desc) {
                reverse = -1;
            }
            
            Long n1 = 0L;
            Long n2 = 0L;
            if(o1 != null && o1.getCreatedate() != null) n1 = o1.getCreatedate();
            if(o2 != null && o2.getCreatedate() != null) n2 = o2.getCreatedate();
            
            return Long.compare(n1, n2) * reverse;
        }
    }
}

