Files
VisualSapfor/src/Common/CurrentAnchestor.java

33 lines
1.2 KiB
Java
Raw Normal View History

package Common;
2024-10-08 16:20:45 +03:00
import Common.Database.Objects.iDBObject;
import Common.Utils.TextLog;
import java.util.LinkedHashMap;
public interface CurrentAnchestor {
2024-10-08 16:20:45 +03:00
default String getDescription(){
return "?";
}
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);
}
}