package usda.weru.mcrew;

import usda.weru.util.Pair;

/**
 * Data structure for holding necessary information for a skel operation tag.
 * small but useful
 * @author cademccumber
 */
public class OperationData {
    private String date;
    private String name;
    private String[] veg_names;                                                     // optional in skel file
    private boolean has_veg_names;
    private Integer yield;
    private Integer res_added; 
    
    public OperationData() {
        this.has_veg_names = false;                                                 // set to true if veg name set
    }
    
    /**
     * Returns true if the operation has vegetation names
     * @return 
     */
    protected boolean hasVeg_names() {
        return this.has_veg_names;
    }
    
    protected void setDate(String date) {
        this.date = date;
    }
    
    protected void setName(String name) {
        this.name = name;
    }
    
    /**
     * Sets the veg names based on a String[] of size 2, each space representing 
     * one of the options that could be used for veg name. [0] = crop name,
     * [1] = residue name
     * @param veg_names 
     */
    protected void setVeg_names(String[] veg_names) {
        if (veg_names.length != 2) {
            this.has_veg_names = false;
            return;
        }
        this.veg_names = veg_names;
        for (String vegname : veg_names) {
            if (vegname != null)
                this.has_veg_names = true;                                          // only set true if one or both has a value set
        }
    }
    
    /**
     * Get operation name
     * @return 
     */
    protected String getName() {
        return this.name;
    }
    
    /**
     * Get operation date
     * @return 
     */
    protected String getDate() {
        return this.date;
    }
    
    /**
     * Gets a String[2] of veg data
     * @returns null if veg names not set
     */
    protected String[] getVeg_names() {
        return this.has_veg_names ? this.veg_names : null;
    }
    
    /**
     * Set the yield from the crop of this operation
     * @param yield 
     */
    protected void setYield(Integer yield) { 
        this.yield = yield;
    }
    
    /**
     * Gets the added yield present in operation if a crop was present in an operation.
     * @return 
     */
    protected Integer getYield() {
        return this.yield;
    }
    
    /**
     * Set the res_added variable
     * @param res_added 
     */
    protected void setRes_added(Integer res_added) {
        this.res_added = res_added;
    }
    
    /**
     * Get the value of this objects res_added value
     * @return 
     */
    protected Integer getRes_added() {
        return this.res_added;
    }
}
