Operation.java [src/nodes] Revision: default Date:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package nodes;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamException;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.xml.sax.SAXException;
import static utils.Constants.ID;
import static utils.Constants.NAME;
import utils.TranslatorException;
/**
*
* @author Brad
*/
public abstract class Operation {
protected String name;
private String id;
protected int rowDirection;
protected double residueAmount;
protected Map<String, Object> properties;
protected Operation() {
properties = new HashMap<>();
}
public String getID() {
return id;
}
public void setID(String key) {
id = key;
}
public String getName() {
return name;
}
public double getResidueAmount() {
return residueAmount;
}
public void setResidueAmount(double residueAmount) {
this.residueAmount = residueAmount;
}
public void readJSONData(JSONObject joperation) throws JSONException {
id = joperation.getString(ID);
name = joperation.getString(NAME);
//rowDirection = joperation.getInt(ROW_DIRECTION);
}
public void addProperty(String name, Object value) {
properties.put(name, value);
}
public abstract void parseLMODData(JSONObject data) throws XMLStreamException, ParserConfigurationException, SAXException, FileNotFoundException, IOException, TranslatorException, JSONException;
@Override
public boolean equals(Object o) {
if (o == null)
return false;
if (o == this)
return true;
if (!(o instanceof Operation))
return false;
Operation op = ( Operation ) o;
return this.id.equals(op.id);
}
@Override
public int hashCode() {
int hash = 7;
hash = 83 * hash + Objects.hashCode(this.name);
hash = 83 * hash + Objects.hashCode(this.id);
return hash;
}
}