parent
5e722ceba6
commit
08d7475257
@ -0,0 +1,43 @@
|
||||
package data;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class DataSource {
|
||||
private HashMap<String, StockType> targets;
|
||||
private String name;
|
||||
private String url;
|
||||
private String apiKey;
|
||||
private String defapi;
|
||||
|
||||
public DataSource(String name, String url, String apiKey, String defapi) {
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
this.apiKey = apiKey;
|
||||
this.defapi = defapi;
|
||||
}
|
||||
|
||||
//Effect: add target to this
|
||||
// add this to target if not already done
|
||||
//Modifies: this, stype
|
||||
public void addStype(StockType stype) {
|
||||
String sname = stype.getClass().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.getClass().getName();
|
||||
if (this.targets.containsKey(sname)) {
|
||||
targets.remove(sname,stype);
|
||||
stype.delSource(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue