Codee sorting and removal off Scollection

This commit is contained in:
7u83 2018-12-23 10:46:53 +01:00
parent 17f6718659
commit 79fc3f303e

View File

@ -35,7 +35,7 @@ import java.util.Random;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import opensesim.sesim.interfaces.GetJson; import opensesim.sesim.interfaces.GetJson;
import opensesim.util.Scollection;
import opensesim.util.SeSimException; import opensesim.util.SeSimException;
import opensesim.util.idgenerator.IDGenerator; import opensesim.util.idgenerator.IDGenerator;
import opensesim.world.scheduler.EventListener; import opensesim.world.scheduler.EventListener;
@ -75,13 +75,11 @@ public class GodWorld implements GetJson, World {
/* HashSet<AbstractAsset> assetsById = new HashSet<>(); /* HashSet<AbstractAsset> assetsById = new HashSet<>();
HashMap<String, AbstractAsset> assetsBySymbol = new HashMap<>(); HashMap<String, AbstractAsset> assetsBySymbol = new HashMap<>();
*/ */
Scollection<String, AbstractAsset> assets = new Scollection<>();
IDGenerator assetIdGenerator = new IDGenerator();
IDGenerator orderIdGenerator = new IDGenerator(); IDGenerator orderIdGenerator = new IDGenerator();
HashSet<AssetPair> assetPairs = new HashSet<>();
private Scheduler scheduler = new Scheduler(); private Scheduler scheduler = new Scheduler();
/** /**
@ -131,7 +129,7 @@ public class GodWorld implements GetJson, World {
continue; continue;
} }
assets.add(a.getSymbol(), a); assets.put(a.getSymbol(), a);
} }
// Read exchanges // Read exchanges
@ -194,7 +192,7 @@ public class GodWorld implements GetJson, World {
throw new SeSimException("Already defined"); throw new SeSimException("Already defined");
} }
assets.add(a.getSymbol(), a); assets.put(a.getSymbol(), a);
return a; return a;
} }
@ -221,27 +219,6 @@ public class GodWorld implements GetJson, World {
return Collections.unmodifiableCollection(exchanges.values()); return Collections.unmodifiableCollection(exchanges.values());
} }
// --------------------------------------------------------------------
// Assets
// --------------------------------------------------------------------
@Override
public Collection<AbstractAsset> getAssetCollection() {
return assets.getCollection(); //Collections.unmodifiableCollection(assetsById);
}
@Override
public AbstractAsset getAssetBySymbol(String symbol) {
return this.assets.get(symbol);
}
public Collection<AssetPair> getAssetPairsCollection() {
return Collections.unmodifiableCollection(assetPairs);
}
public void add(AssetPair pair) {
assetPairs.add(pair);
}
public Exchange addExchange(String symbol) throws SeSimException { public Exchange addExchange(String symbol) throws SeSimException {
for (Exchange ex : getExchangeCollection()) { for (Exchange ex : getExchangeCollection()) {
if (ex.getSymbol().equals(symbol)) { if (ex.getSymbol().equals(symbol)) {
@ -255,6 +232,35 @@ public class GodWorld implements GetJson, World {
return null; return null;
} }
// --------------------------------------------------------------------
// Assets
// --------------------------------------------------------------------
private final HashMap<String, AbstractAsset> assets = new HashMap<>();
@Override
public Collection<AbstractAsset> getAssetCollection() {
return Collections.unmodifiableCollection(assets.values());
}
@Override
public AbstractAsset getAssetBySymbol(String symbol) {
return this.assets.get(symbol);
}
// --------------------------------------------------------------------
// AssetsPairs
// --------------------------------------------------------------------
private final HashSet<AssetPair> asset_pairs = new HashSet<>();
public Collection<AssetPair> getAssetPairsCollection() {
return Collections.unmodifiableCollection(asset_pairs);
}
public void add(AssetPair pair) {
asset_pairs.add(pair);
}
/* public AbstractAsset createAsset(long key, JSONObject cfg) throws SeSimException{ /* public AbstractAsset createAsset(long key, JSONObject cfg) throws SeSimException{
if (key!=masterkey) if (key!=masterkey)
throw new SeSimException("Access denied."); throw new SeSimException("Access denied.");
@ -369,6 +375,9 @@ public class GodWorld implements GetJson, World {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// Stuff belonging to accounts // Stuff belonging to accounts
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// Pseudo random generator stuff // Pseudo random generator stuff
// -------------------------------------------------------------------- // --------------------------------------------------------------------