/*
 * Copyright
 *   2009 axYus - www.axyus.com
 *   2009 C.Marchand - christophe.marchand@axyus.com
 *
 * This file is part of XEMELIOS.
 *
 * XEMELIOS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * XEMELIOS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with XEMELIOS; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package fr.gouv.finances.dgfip.xemelios.web.gwt.client.dto;

import com.google.gwt.user.client.rpc.IsSerializable;

/**
 *
 * @author chm
 */
public class DisplayableFieldDTO implements IsSerializable {

    public static final int SORT_POSITION_NO_SORT = -1;
    public static final int SORT_ORDER_NO_SORT = -1;
    public static final int SORT_ORDER_ASC = 0;
    public static final int SORT_ORDER_DESC = 1;
    private String id, libelle;
    private boolean display;
    private int sortPosition = -1;
    private int sortOrder = -1;

    public DisplayableFieldDTO() {
        super();
        id = null;
        libelle = null;
        display = false;
    }
    public DisplayableFieldDTO(String id, String libelle) {
        this();
        this.id=id;
        this.libelle=libelle;
    }
    public DisplayableFieldDTO(String id, String libelle,boolean display) {
        this(id,libelle);
        this.display=display;
    }
    public DisplayableFieldDTO(String id,String libelle, boolean display, int sortPosition, int sortOrder) {
        this(id,libelle,display);
        this.sortPosition=sortPosition;
        this.sortOrder=sortOrder;
    }

    public boolean isDisplay() {
        return display;
    }

    public void setDisplay(boolean display) {
        this.display = display;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getLibelle() {
        return libelle;
    }

    public void setLibelle(String libelle) {
        this.libelle = libelle;
    }

    public int getSortOrder() {
        return sortOrder;
    }

    public void setSortOrder(int sortOrder) {
        this.sortOrder = sortOrder;
    }

    public int getSortPosition() {
        return sortPosition;
    }

    public void setSortPosition(int sortPosition) {
        this.sortPosition = sortPosition;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final DisplayableFieldDTO other = (DisplayableFieldDTO) obj;
        if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 59 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append("<champ id=\"").append(id).append("\" libelle=\"").append(libelle).append("\" display=\"").append(Boolean.toString(display)).append("\" sort-pos=\"").append(sortPosition).append("\" order=\"").append(sortOrder).append("\"/>");
        return sb.toString();
    }

}
