рефакторинг. переносил текущие объекты в другое место
This commit is contained in:
@@ -1,19 +1,23 @@
|
||||
package MainModule_;
|
||||
import Common.Current_;
|
||||
import Common.Database.Objects.iDBObject;
|
||||
import Common.Database.VisualiserDatabase;
|
||||
import Common.Passes.Pass;
|
||||
import Common.Passes.PassCode_;
|
||||
import Common.Utils.Utils_;
|
||||
import Common.Utils.TextLog;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
//Основной объект визуализатора.
|
||||
public abstract class MainModule_<D extends VisualiserDatabase> {
|
||||
protected D db;
|
||||
protected Class<D> db_class;
|
||||
public LinkedHashMap<PassCode_, Pass> passes;
|
||||
D db;
|
||||
Class<D> db_class;
|
||||
LinkedHashMap<PassCode_, Pass> passes;
|
||||
LinkedHashMap<Current_, Object> objects;
|
||||
public D getDb() {
|
||||
return db;
|
||||
}
|
||||
public MainModule_(Class<D> db_class_in) {
|
||||
objects = new LinkedHashMap<>();
|
||||
try {
|
||||
db_class = db_class_in;
|
||||
} catch (Exception ex) {
|
||||
@@ -30,4 +34,26 @@ public abstract class MainModule_<D extends VisualiserDatabase> {
|
||||
public void DeactivateDB() throws Exception{
|
||||
if (db != null) db.Disconnect();
|
||||
}
|
||||
//--
|
||||
public Object get(Current_ name) {
|
||||
if (!objects.containsKey(name))
|
||||
objects.put(name,null);
|
||||
return objects.get(name);
|
||||
}
|
||||
public Object set(Current_ name, Object object) {
|
||||
if (objects.containsKey(name))
|
||||
objects.replace(name, object);
|
||||
else objects.put(name, object);
|
||||
return object;
|
||||
}
|
||||
public boolean Check(TextLog Log, Current_... names) {
|
||||
for (Current_ name : names)
|
||||
if (get(name) == null)
|
||||
Log.Writeln_(name.getDescription() + " не выбран(а)");
|
||||
return Log.isEmpty();
|
||||
}
|
||||
//применять только для наследников iDBObject
|
||||
public boolean matchCurrentID(Current_ name, int id) {
|
||||
return (get(name) != null) && (((iDBObject) get(name)).id == id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user