/*
 * Copyright 2009 Lari Natri <lari.natri@gmail.com>
 *
 *  This program 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 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 */


package compid.data.tuples;

import java.util.HashMap;

/**
 *
 * @author Lari Natri
 */
public final class Query extends Tuple {
    
    public static final String TABLELABEL = "QUERY";

    private DatasetInfo dataSetInfo = null;
    private final double observedMass;
    private final double charge;
    private final String scantitle;
    
    public Query(DatasetInfo dataSetInfo, String scantitle, double observedMass, double charge) {
        this.dataSetInfo = dataSetInfo;
        this.scantitle = scantitle;
        this.observedMass = observedMass;
        this.charge = charge;
        if (this.dataSetInfo==null)
            throw new NullPointerException("Dataset must be defined.");
    }
    
    public DatasetInfo getDataSetInfo() { return this.dataSetInfo; }
    
    public double getObservedMass() { return this.observedMass; }
    
    public double getCharge() { return this.charge; }

    public String getScanTitle() { return this.scantitle; }
    
    public void setDataSetInfo(DatasetInfo dataSetInfo) {
        if (dataSetInfo==null) return;
        this.dataSetInfo = dataSetInfo;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Query other = (Query) obj;
        if (this.dataSetInfo != other.dataSetInfo && (this.dataSetInfo == null || !this.dataSetInfo.equals(other.dataSetInfo))) {
            return false;
        }
        if (this.observedMass != other.observedMass) {
            return false;
        }
        if (this.charge != other.charge) {
            return false;
        }
        if ((this.scantitle == null) ? (other.scantitle != null) : !this.scantitle.equals(other.scantitle)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 89 * hash + (this.dataSetInfo != null ? this.dataSetInfo.hashCode() : 0);
        hash = 89 * hash + (int) (Double.doubleToLongBits(this.observedMass) ^ (Double.doubleToLongBits(this.observedMass) >>> 32));
        hash = 89 * hash + (int) (Double.doubleToLongBits(this.charge) ^ (Double.doubleToLongBits(this.charge) >>> 32));
        hash = 89 * hash + (this.scantitle != null ? this.scantitle.hashCode() : 0);
        return hash;
    }


    

    @Override
    public String getTableLabel() {
        return TABLELABEL;
    }

    @Override
    public HashMap<String,Object> getColsAndValues() {
        HashMap<String,Object> map = new HashMap<String,Object>(3,1);
        map.put("SCANTITLE", scantitle);
        map.put("SUBMITTEDMASS", this.observedMass);
        // map.put("PREDICTEDMASS", this.predictedMass);
        map.put("CHARGE", this.charge);
        return map;
    }    
    

    
}

