package data; import java.util.Set; import java.util.Map; import java.util.HashMap; import java.util.Iterator; import java.util.Objects; public abstract class DataSource { protected HashMap targets; protected String name; protected String url; protected String apiKey; public DataSource(String name, String url, String apiKey) { this.targets = new HashMap(); this.name = name; this.url = url; this.apiKey = apiKey; } //Effect: add target to this // add this to target if not already done //Modifies: this, stype public void addStype(StockType stype) { String sname = stype.getName(); if (!this.targets.containsKey(sname)) { targets.put(sname,stype); stype.addSource(this); } } //Effect: del target to this // del this to target if not already done //Modifies: this, stype public void delStype(StockType stype) { String sname = stype.getName(); if (this.targets.containsKey(sname)) { targets.remove(sname,stype); stype.delSource(this); } } public String getName() { return name; } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DataSource)) { return false; } DataSource temp = (DataSource) obj; if (temp.getName().equals(name)) { return true; } return false; } @Override public int hashCode() { return Objects.hash(name); } public abstract double[] update(String stype, String idstring); }