2024-10-08 00:39:13 +03:00
|
|
|
|
package Common;
|
2024-10-08 16:20:45 +03:00
|
|
|
|
import Common.Database.Objects.iDBObject;
|
2024-10-08 00:39:13 +03:00
|
|
|
|
import Common.Utils.TextLog;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
|
public interface CurrentAnchestor {
|
2024-10-08 16:20:45 +03:00
|
|
|
|
default String getDescription(){
|
|
|
|
|
|
return "?";
|
|
|
|
|
|
}
|
2024-10-08 00:39:13 +03:00
|
|
|
|
LinkedHashMap<CurrentAnchestor, Object> objects = new LinkedHashMap<>();
|
|
|
|
|
|
static Object get(CurrentAnchestor name) {
|
|
|
|
|
|
if (!objects.containsKey(name))
|
|
|
|
|
|
objects.put(name,null);
|
|
|
|
|
|
return objects.get(name);
|
|
|
|
|
|
}
|
|
|
|
|
|
static Object set(CurrentAnchestor name, Object object) {
|
|
|
|
|
|
if (objects.containsKey(name))
|
|
|
|
|
|
objects.replace(name, object);
|
|
|
|
|
|
else objects.put(name, object);
|
|
|
|
|
|
return object;
|
|
|
|
|
|
}
|
|
|
|
|
|
static boolean Check(TextLog Log, CurrentAnchestor... names) {
|
|
|
|
|
|
for (CurrentAnchestor name : names)
|
|
|
|
|
|
if (CurrentAnchestor.get(name) == null)
|
|
|
|
|
|
Log.Writeln_(name.getDescription() + " не выбран(а)");
|
|
|
|
|
|
return Log.isEmpty();
|
|
|
|
|
|
}
|
2024-10-08 16:20:45 +03:00
|
|
|
|
//применять только для наследников iDBObject
|
|
|
|
|
|
static boolean matchCurrentID(CurrentAnchestor name, int id) {
|
|
|
|
|
|
return (CurrentAnchestor.get(name) != null) && (((iDBObject) CurrentAnchestor.get(name)).id == id);
|
|
|
|
|
|
}
|
2024-10-08 00:39:13 +03:00
|
|
|
|
}
|