From 9ea5cd9277cff2b5f89b8342f18ee49fbdd78c17 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Wed, 27 Dec 2023 14:21:52 +0200 Subject: [PATCH] refactor: remove old Data API --- src/me/topchetoeu/jscript/engine/Data.java | 56 ------------------- src/me/topchetoeu/jscript/engine/DataKey.java | 3 - 2 files changed, 59 deletions(-) delete mode 100644 src/me/topchetoeu/jscript/engine/Data.java delete mode 100644 src/me/topchetoeu/jscript/engine/DataKey.java diff --git a/src/me/topchetoeu/jscript/engine/Data.java b/src/me/topchetoeu/jscript/engine/Data.java deleted file mode 100644 index 54b78a2..0000000 --- a/src/me/topchetoeu/jscript/engine/Data.java +++ /dev/null @@ -1,56 +0,0 @@ -package me.topchetoeu.jscript.engine; - -import java.util.HashMap; -import java.util.Map; - -@SuppressWarnings("unchecked") -public class Data { - private HashMap, Object> data = new HashMap<>(); - - public Data copy() { - return new Data().addAll(this); - } - - public Data addAll(Map, ?> data) { - for (var el : data.entrySet()) { - get((DataKey)el.getKey(), (Object)el.getValue()); - } - return this; - } - public Data addAll(Data data) { - for (var el : data.data.entrySet()) { - get((DataKey)el.getKey(), (Object)el.getValue()); - } - return this; - } - - public T remove(DataKey key) { - return (T)data.remove(key); - } - public Data set(DataKey key, T val) { - data.put((DataKey)key, (Object)val); - return this; - } - public T get(DataKey key, T val) { - if (data.containsKey(key)) return (T)data.get((DataKey)key); - set(key, val); - return val; - } - public T get(DataKey key) { - if (data.containsKey(key)) return (T)data.get((DataKey)key); - return null; - } - public boolean has(DataKey key) { return data.containsKey(key); } - - public int increase(DataKey key, int n, int start) { - int res; - set(key, res = get(key, start) + n); - return res; - } - public int increase(DataKey key, int n) { - return increase(key, n, 0); - } - public int increase(DataKey key) { - return increase(key, 1, 0); - } -} diff --git a/src/me/topchetoeu/jscript/engine/DataKey.java b/src/me/topchetoeu/jscript/engine/DataKey.java deleted file mode 100644 index 017fa2a..0000000 --- a/src/me/topchetoeu/jscript/engine/DataKey.java +++ /dev/null @@ -1,3 +0,0 @@ -package me.topchetoeu.jscript.engine; - -public class DataKey { } \ No newline at end of file