package Common; import Common.Database.Objects.iDBObject; import Common.Utils.TextLog; import java.util.LinkedHashMap; public interface CurrentAnchestor { default String getDescription(){ return "?"; } LinkedHashMap 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(); } //применять только для наследников iDBObject static boolean matchCurrentID(CurrentAnchestor name, int id) { return (CurrentAnchestor.get(name) != null) && (((iDBObject) CurrentAnchestor.get(name)).id == id); } }