diff --git a/Plan/common/src/main/java/com/djrapitops/plan/data/container/Session.java b/Plan/common/src/main/java/com/djrapitops/plan/data/container/Session.java
index 2feb73bbd..da909cace 100644
--- a/Plan/common/src/main/java/com/djrapitops/plan/data/container/Session.java
+++ b/Plan/common/src/main/java/com/djrapitops/plan/data/container/Session.java
@@ -16,7 +16,7 @@
*/
package com.djrapitops.plan.data.container;
-import com.djrapitops.plan.data.store.containers.DataContainer;
+import com.djrapitops.plan.data.store.containers.SupplierDataContainer;
import com.djrapitops.plan.data.store.keys.SessionKeys;
import com.djrapitops.plan.data.store.objects.DateHolder;
import com.djrapitops.plan.data.time.WorldTimes;
@@ -29,7 +29,7 @@ import java.util.*;
* @author Rsl1122
* @see SessionKeys for Key objects.
*/
-public class Session extends DataContainer implements DateHolder {
+public class Session extends SupplierDataContainer implements DateHolder {
private long sessionStart;
private WorldTimes worldTimes;
diff --git a/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/AnalysisContainer.java b/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/AnalysisContainer.java
index 80f32e751..2f1ab57d5 100644
--- a/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/AnalysisContainer.java
+++ b/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/AnalysisContainer.java
@@ -59,7 +59,7 @@ import java.util.stream.Collectors;
* @see com.djrapitops.plan.data.store.keys.AnalysisKeys for Key objects
* @see com.djrapitops.plan.data.store.PlaceholderKey for placeholder information
*/
-public class AnalysisContainer extends DataContainer {
+public class AnalysisContainer extends SupplierDataContainer {
private final ServerContainer serverContainer;
diff --git a/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/DataContainer.java b/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/DataContainer.java
index 4a6ec2a6e..c2f508da8 100644
--- a/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/DataContainer.java
+++ b/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/DataContainer.java
@@ -16,67 +16,56 @@
*/
package com.djrapitops.plan.data.store.containers;
-import com.djrapitops.plan.data.store.CachingSupplier;
import com.djrapitops.plan.data.store.Key;
import com.djrapitops.plan.utilities.formatting.Formatter;
-import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
-import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
-import java.util.stream.Collectors;
/**
- * Abstract representation of an object that holds the Values for different Keys.
+ * Interface for an object that can store arbitrary data referenced via {@link Key} objects.
*
- * The methods in this object are used for placing and fetching the data from the container.
- * Methods to use depend on your use case.
+ * Implementations should mainly be concerned on how the data given to it is stored.
+ * Retrieval has some details that should be followed.
*
* @author Rsl1122
*/
-public class DataContainer {
-
- private final Map map;
- private long timeToLive;
-
- public DataContainer() {
- this(TimeUnit.SECONDS.toMillis(30L));
- }
-
- public DataContainer(long timeToLive) {
- this.timeToLive = timeToLive;
- map = new HashMap<>();
- }
+public interface DataContainer {
/**
* Place your data inside the container.
+ *
+ * What the container does with the object depends on the implementation.
*
* @param key Key of type T that identifies the data and will be used later when the data needs to be fetched.
* @param obj object to store
* @param Type of the object
*/
- public void putRawData(Key key, T obj) {
- putSupplier(key, () -> obj);
- }
+ void putRawData(Key key, T obj);
- public void putSupplier(Key key, Supplier supplier) {
- if (supplier == null) {
- return;
- }
- map.put(key, supplier);
- }
+ /**
+ * Place a data supplier inside the container.
+ *
+ * What the container does with the supplier depends on the implementation.
+ *
+ * @param key Key of type T that identifies the data and will be used later when the data needs to be fetched.
+ * @param supplier Supplier to store
+ * @param Type of the object
+ */
+ void putSupplier(Key key, Supplier supplier);
- public void putCachingSupplier(Key key, Supplier supplier) {
- if (supplier == null) {
- return;
- }
- map.put(key, new CachingSupplier<>(supplier, timeToLive));
- }
-
- private Supplier getSupplier(Key key) {
- return (Supplier) map.get(key);
- }
+ /**
+ * Place a caching data supplier inside the container.
+ *
+ * If the supplier is called the value is cached according to the implementation of the container.
+ * What the container does with the supplier depends on the implementation.
+ *
+ * @param key Key of type T that identifies the data and will be used later when the data needs to be fetched.
+ * @param supplier Supplier to store
+ * @param Type of the object
+ */
+ void putCachingSupplier(Key key, Supplier supplier);
/**
* Check if a Value with the given Key has been placed into the container.
@@ -85,65 +74,79 @@ public class DataContainer {
* @param Type of the object returned by the Value if it is present.
* @return true if found, false if not.
*/
- public boolean supports(Key key) {
- return map.containsKey(key);
- }
+ boolean supports(Key key);
/**
- * Get an Optional of the data identified by the Key.
+ * Get an Optional of the Value identified by the Key.
*
- * Since Value is a functional interface, its method may call blocking methods via Value implementations,
- * It is therefore recommended to not call this method on the server thread.
- *
- * It is recommended to check if the Optional is present as null values returned by plugins will be empty.
+ * It is recommended to check if the Optional is present as null values will be empty.
*
* @param key Key that identifies the Value
* @param Type of the object returned by Value
* @return Optional of the object if the key is registered and key matches the type of the object. Otherwise empty.
*/
- public Optional getValue(Key key) {
- Supplier supplier = getSupplier(key);
- if (supplier == null) {
- return Optional.empty();
- }
- try {
- return Optional.ofNullable(supplier.get());
- } catch (ClassCastException e) {
- return Optional.empty();
- }
- }
+ Optional getValue(Key key);
- public T getUnsafe(Key key) {
- Supplier supplier = map.get(key);
- if (supplier == null) {
- throw new IllegalArgumentException("Unsupported Key: " + key.getKeyName());
- }
- return (T) supplier.get();
- }
+ /**
+ * Get data identified by the Key, or throw an exception.
+ *
+ * It is recommended to use {@link DataContainer#supports(Key)} before using this method.
+ *
+ * @param key Key that identifies the Value
+ * @param Type of the object returned by Value
+ * @return the value
+ * @throws IllegalArgumentException If the key is not supported.
+ */
+ T getUnsafe(Key key);
- public String getFormatted(Key key, Formatter> formatter) {
+ /**
+ * Get formatted Value identified by the Key.
+ *
+ *
+ * @param key Key that identifies the Value
+ * @param formatter Formatter for the Optional returned by {@link DataContainer#getValue(Key)}
+ * @param Type of the object returned by Value
+ * @return Optional of the object if the key is registered and key matches the type of the object. Otherwise empty.
+ */
+ default String getFormatted(Key key, Formatter> formatter) {
Optional value = getValue(key);
return formatter.apply(value);
}
- public String getFormattedUnsafe(Key key, Formatter formatter) {
+ /**
+ * Get formatted Value identified by the Key, or throw an exception.
+ *
+ * It is recommended to use {@link DataContainer#supports(Key)} before using this method.
+ *
+ * @param key Key that identifies the Value
+ * @param formatter Formatter for the value
+ * @param Type of the object returned by Value
+ * @return the value
+ * @throws IllegalArgumentException If the key is not supported.
+ */
+ default String getFormattedUnsafe(Key key, Formatter formatter) {
T value = getUnsafe(key);
return formatter.apply(value);
}
- private void putAll(Map toPut) {
- map.putAll(toPut);
- }
+ /**
+ * Place all values from given DataContainer into this container.
+ *
+ * @param dataContainer Container with values.
+ */
+ void putAll(DataContainer dataContainer);
- public void putAll(DataContainer dataContainer) {
- putAll(dataContainer.map);
- }
+ /**
+ * Clear the container of all data.
+ */
+ void clear();
- public void clear() {
- map.clear();
- }
-
- public Map getMap() {
- return map.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().get()));
- }
-}
\ No newline at end of file
+ /**
+ * Return a Key - Value Map of the data in the container.
+ *
+ * This method may call blocking methods if underlying implementation uses the given Suppliers.
+ *
+ * @return Map: Key - Object
+ */
+ Map getMap();
+}
diff --git a/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/NetworkContainer.java b/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/NetworkContainer.java
index 677b6301a..90ad515c2 100644
--- a/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/NetworkContainer.java
+++ b/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/NetworkContainer.java
@@ -56,7 +56,7 @@ import java.util.concurrent.TimeUnit;
* @see com.djrapitops.plan.data.store.keys.NetworkKeys for Key objects
* @see com.djrapitops.plan.data.store.PlaceholderKey for placeholder information
*/
-public class NetworkContainer extends DataContainer {
+public class NetworkContainer extends SupplierDataContainer {
private final ServerContainer bungeeContainer;
diff --git a/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/PlayerContainer.java b/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/PlayerContainer.java
index 480d2f6e5..3eb44892b 100644
--- a/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/PlayerContainer.java
+++ b/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/PlayerContainer.java
@@ -30,7 +30,7 @@ import java.util.Map;
* @author Rsl1122
* @see com.djrapitops.plan.data.store.keys.PlayerKeys For Key objects.
*/
-public class PlayerContainer extends DataContainer {
+public class PlayerContainer extends SupplierDataContainer {
private Map activityIndexCache;
diff --git a/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/ServerContainer.java b/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/ServerContainer.java
index 8a229465f..809ed2818 100644
--- a/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/ServerContainer.java
+++ b/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/ServerContainer.java
@@ -22,5 +22,5 @@ package com.djrapitops.plan.data.store.containers;
* @author Rsl1122
* @see com.djrapitops.plan.data.store.keys.ServerKeys For Key objects.
*/
-public class ServerContainer extends DataContainer {
+public class ServerContainer extends SupplierDataContainer {
}
\ No newline at end of file
diff --git a/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/SupplierDataContainer.java b/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/SupplierDataContainer.java
new file mode 100644
index 000000000..ec0d9f40a
--- /dev/null
+++ b/Plan/common/src/main/java/com/djrapitops/plan/data/store/containers/SupplierDataContainer.java
@@ -0,0 +1,133 @@
+/*
+ * This file is part of Player Analytics (Plan).
+ *
+ * Plan is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License v3 as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Plan is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Plan. If not, see .
+ */
+package com.djrapitops.plan.data.store.containers;
+
+import com.djrapitops.plan.data.store.CachingSupplier;
+import com.djrapitops.plan.data.store.Key;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+
+/**
+ * Abstract representation of an object that holds the Values for different Keys.
+ *
+ * The methods in this object are used for placing and fetching the data from the container.
+ * Methods to use depend on your use case.
+ *
+ * @author Rsl1122
+ */
+public class SupplierDataContainer implements DataContainer {
+
+ private final Map map;
+ private long timeToLive;
+
+ /**
+ * Create a SupplierDataContainer with a default TTL of 30 seconds.
+ */
+ public SupplierDataContainer() {
+ this(TimeUnit.SECONDS.toMillis(30L));
+ }
+
+ /**
+ * Create a SupplierDataContainer with a custom TTL.
+ *
+ * The old value is not removed from memory until the supplier is called again.
+ *
+ * @param timeToLive TTL that determines how long a CachingSupplier value is deemed valid.
+ */
+ public SupplierDataContainer(long timeToLive) {
+ this.timeToLive = timeToLive;
+ map = new HashMap<>();
+ }
+
+ @Override
+ public void putRawData(Key key, T obj) {
+ putSupplier(key, () -> obj);
+ }
+
+ @Override
+ public void putSupplier(Key key, Supplier supplier) {
+ if (supplier == null) {
+ return;
+ }
+ map.put(key, supplier);
+ }
+
+ @Override
+ public void putCachingSupplier(Key key, Supplier supplier) {
+ if (supplier == null) {
+ return;
+ }
+ map.put(key, new CachingSupplier<>(supplier, timeToLive));
+ }
+
+ private Supplier getSupplier(Key key) {
+ return (Supplier) map.get(key);
+ }
+
+ @Override
+ public boolean supports(Key key) {
+ return map.containsKey(key);
+ }
+
+ @Override
+ public Optional getValue(Key key) {
+ Supplier supplier = getSupplier(key);
+ if (supplier == null) {
+ return Optional.empty();
+ }
+ try {
+ return Optional.ofNullable(supplier.get());
+ } catch (ClassCastException e) {
+ return Optional.empty();
+ }
+ }
+
+ @Override
+ public T getUnsafe(Key key) {
+ Supplier supplier = map.get(key);
+ if (supplier == null) {
+ throw new IllegalArgumentException("Unsupported Key: " + key.getKeyName());
+ }
+ return (T) supplier.get();
+ }
+
+ private void putAll(Map toPut) {
+ map.putAll(toPut);
+ }
+
+ @Override
+ public void putAll(DataContainer dataContainer) {
+ if (dataContainer instanceof SupplierDataContainer) {
+ putAll(((SupplierDataContainer) dataContainer).map);
+ }
+ }
+
+ @Override
+ public void clear() {
+ map.clear();
+ }
+
+ @Override
+ public Map getMap() {
+ return map.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().get()));
+ }
+}
\ No newline at end of file
diff --git a/Plan/common/src/main/java/com/djrapitops/plan/data/store/mutators/health/NetworkHealthInformation.java b/Plan/common/src/main/java/com/djrapitops/plan/data/store/mutators/health/NetworkHealthInformation.java
index 1c3074bd5..e45310bc6 100644
--- a/Plan/common/src/main/java/com/djrapitops/plan/data/store/mutators/health/NetworkHealthInformation.java
+++ b/Plan/common/src/main/java/com/djrapitops/plan/data/store/mutators/health/NetworkHealthInformation.java
@@ -19,6 +19,7 @@ package com.djrapitops.plan.data.store.mutators.health;
import com.djrapitops.plan.data.store.Key;
import com.djrapitops.plan.data.store.containers.DataContainer;
import com.djrapitops.plan.data.store.containers.NetworkContainer;
+import com.djrapitops.plan.data.store.containers.SupplierDataContainer;
import com.djrapitops.plan.data.store.keys.AnalysisKeys;
import com.djrapitops.plan.data.store.keys.NetworkKeys;
import com.djrapitops.plan.data.store.mutators.PlayersMutator;
@@ -146,7 +147,7 @@ public class NetworkHealthInformation extends AbstractHealthInfo {
for (Server server : servers) {
UUID serverUUID = server.getUuid();
- DataContainer serverContainer = new DataContainer();
+ DataContainer serverContainer = new SupplierDataContainer();
serverContainer.putRawData(serverKey, server);
PlayersMutator serverPlayers = playersMutator.filterPlayedOnServer(serverUUID);
diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/containers/AllPlayerContainersQuery.java b/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/containers/AllPlayerContainersQuery.java
index 7961089a2..5556b84fb 100644
--- a/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/containers/AllPlayerContainersQuery.java
+++ b/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/containers/AllPlayerContainersQuery.java
@@ -20,6 +20,7 @@ import com.djrapitops.plan.data.container.*;
import com.djrapitops.plan.data.store.containers.DataContainer;
import com.djrapitops.plan.data.store.containers.PerServerContainer;
import com.djrapitops.plan.data.store.containers.PlayerContainer;
+import com.djrapitops.plan.data.store.containers.SupplierDataContainer;
import com.djrapitops.plan.data.store.keys.PerServerKeys;
import com.djrapitops.plan.data.store.keys.PlayerKeys;
import com.djrapitops.plan.data.store.mutators.PerServerMutator;
@@ -61,7 +62,7 @@ public class AllPlayerContainersQuery implements Query> {
continue;
}
PerServerContainer perServerContainer = perServerContainers.getOrDefault(uuid, new PerServerContainer());
- DataContainer container = perServerContainer.getOrDefault(serverUUID, new DataContainer());
+ DataContainer container = perServerContainer.getOrDefault(serverUUID, new SupplierDataContainer());
container.putRawData(PlayerKeys.REGISTERED, userInfo.getRegistered());
container.putRawData(PlayerKeys.BANNED, userInfo.isBanned());
container.putRawData(PlayerKeys.OPERATOR, userInfo.isOperator());
@@ -77,7 +78,7 @@ public class AllPlayerContainersQuery implements Query> {
for (Map.Entry> sessionEntry : serverUserSessions.entrySet()) {
UUID uuid = sessionEntry.getKey();
PerServerContainer perServerContainer = perServerContainers.getOrDefault(uuid, new PerServerContainer());
- DataContainer container = perServerContainer.getOrDefault(serverUUID, new DataContainer());
+ DataContainer container = perServerContainer.getOrDefault(serverUUID, new SupplierDataContainer());
List serverSessions = sessionEntry.getValue();
container.putRawData(PerServerKeys.SESSIONS, serverSessions);
@@ -103,7 +104,7 @@ public class AllPlayerContainersQuery implements Query> {
for (Ping ping : entry.getValue()) {
UUID serverUUID = ping.getServerUUID();
PerServerContainer perServerContainer = perServerContainers.getOrDefault(uuid, new PerServerContainer());
- DataContainer container = perServerContainer.getOrDefault(serverUUID, new DataContainer());
+ DataContainer container = perServerContainer.getOrDefault(serverUUID, new SupplierDataContainer());
if (!container.supports(PerServerKeys.PING)) {
container.putRawData(PerServerKeys.PING, new ArrayList<>());
diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/containers/PerServerContainerQuery.java b/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/containers/PerServerContainerQuery.java
index fb50e41bc..f0c7d6cd9 100644
--- a/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/containers/PerServerContainerQuery.java
+++ b/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/containers/PerServerContainerQuery.java
@@ -21,6 +21,7 @@ import com.djrapitops.plan.data.container.UserInfo;
import com.djrapitops.plan.data.store.Key;
import com.djrapitops.plan.data.store.containers.DataContainer;
import com.djrapitops.plan.data.store.containers.PerServerContainer;
+import com.djrapitops.plan.data.store.containers.SupplierDataContainer;
import com.djrapitops.plan.data.store.keys.PerServerKeys;
import com.djrapitops.plan.data.store.keys.PlayerKeys;
import com.djrapitops.plan.data.store.mutators.SessionsMutator;
@@ -70,7 +71,7 @@ public class PerServerContainerQuery implements Query {
UUID serverUUID = entry.getKey();
List serverSessions = entry.getValue();
- DataContainer serverContainer = perServerContainer.getOrDefault(serverUUID, new DataContainer());
+ DataContainer serverContainer = perServerContainer.getOrDefault(serverUUID, new SupplierDataContainer());
serverContainer.putRawData(PerServerKeys.SESSIONS, serverSessions);
serverContainer.putSupplier(PerServerKeys.PLAYER_KILLS, () -> SessionsMutator.forContainer(serverContainer).toPlayerKillList());
@@ -123,7 +124,7 @@ public class PerServerContainerQuery implements Query {
}
private void placeToPerServerContainer(UUID serverUUID, Key key, T value, PerServerContainer perServerContainer) {
- DataContainer container = perServerContainer.getOrDefault(serverUUID, new DataContainer());
+ DataContainer container = perServerContainer.getOrDefault(serverUUID, new SupplierDataContainer());
container.putRawData(key, value);
perServerContainer.put(serverUUID, container);
}
diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/UsersTable.java b/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/UsersTable.java
index 2bc7eb850..06932b7de 100644
--- a/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/UsersTable.java
+++ b/Plan/common/src/main/java/com/djrapitops/plan/db/sql/tables/UsersTable.java
@@ -18,6 +18,7 @@ package com.djrapitops.plan.db.sql.tables;
import com.djrapitops.plan.data.store.Key;
import com.djrapitops.plan.data.store.containers.DataContainer;
+import com.djrapitops.plan.data.store.containers.SupplierDataContainer;
import com.djrapitops.plan.data.store.keys.PlayerKeys;
import com.djrapitops.plan.db.DBType;
import com.djrapitops.plan.db.SQLDB;
@@ -297,7 +298,7 @@ public class UsersTable extends Table {
public DataContainer getUserInformation(UUID uuid) {
Key user_data = new Key<>(DataContainer.class, "plan_users_data");
- DataContainer returnValue = new DataContainer();
+ DataContainer returnValue = new SupplierDataContainer();
returnValue.putSupplier(user_data, () -> getUserInformationDataContainer(uuid));
returnValue.putRawData(PlayerKeys.UUID, uuid);
@@ -318,7 +319,7 @@ public class UsersTable extends Table {
@Override
public DataContainer processResults(ResultSet set) throws SQLException {
- DataContainer container = new DataContainer();
+ DataContainer container = new SupplierDataContainer();
if (set.next()) {
long registered = set.getLong(REGISTERED);
diff --git a/Plan/common/src/test/java/com/djrapitops/plan/data/store/containers/DataContainerTest.java b/Plan/common/src/test/java/com/djrapitops/plan/data/store/containers/SupplierDataContainerTest.java
similarity index 82%
rename from Plan/common/src/test/java/com/djrapitops/plan/data/store/containers/DataContainerTest.java
rename to Plan/common/src/test/java/com/djrapitops/plan/data/store/containers/SupplierDataContainerTest.java
index 3876590c3..7db86c410 100644
--- a/Plan/common/src/test/java/com/djrapitops/plan/data/store/containers/DataContainerTest.java
+++ b/Plan/common/src/test/java/com/djrapitops/plan/data/store/containers/SupplierDataContainerTest.java
@@ -22,18 +22,18 @@ import org.junit.Test;
import static org.junit.Assert.*;
/**
- * Test for {@link DataContainer} programming errors.
+ * Test for {@link SupplierDataContainer} programming errors.
*
* @author Rsl1122
*/
-public class DataContainerTest {
+public class SupplierDataContainerTest {
private static final Key TEST_KEY = new Key<>(String.class, "TEST_KEY");
private static final Key TEST_KEY_COPY = new Key<>(String.class, "TEST_KEY");
@Test
public void safeUnsafeKeySupplierSameObject() {
- DataContainer container = new DataContainer();
+ DataContainer container = new SupplierDataContainer();
container.putSupplier(TEST_KEY, () -> "Success");
assertEquals("Success", container.getUnsafe(TEST_KEY));
@@ -41,7 +41,7 @@ public class DataContainerTest {
@Test
public void safeUnsafeKeySupplierDifferentObject() {
- DataContainer container = new DataContainer();
+ DataContainer container = new SupplierDataContainer();
container.putSupplier(TEST_KEY, () -> "Success");
assertEquals("Success", container.getUnsafe(TEST_KEY_COPY));
@@ -49,7 +49,7 @@ public class DataContainerTest {
@Test
public void safeUnsafeKeyRawSameObject() {
- DataContainer container = new DataContainer();
+ DataContainer container = new SupplierDataContainer();
container.putRawData(TEST_KEY, "Success");
assertEquals("Success", container.getUnsafe(TEST_KEY));
@@ -57,7 +57,7 @@ public class DataContainerTest {
@Test
public void safeUnsafeKeyRawDifferentObject() {
- DataContainer container = new DataContainer();
+ DataContainer container = new SupplierDataContainer();
container.putRawData(TEST_KEY, "Success");
assertEquals("Success", container.getUnsafe(TEST_KEY_COPY));
@@ -65,7 +65,7 @@ public class DataContainerTest {
@Test
public void safeUnsafeKeyRawNull() {
- DataContainer container = new DataContainer();
+ DataContainer container = new SupplierDataContainer();
container.putRawData(TEST_KEY, null);
assertTrue(container.supports(TEST_KEY));
@@ -74,7 +74,7 @@ public class DataContainerTest {
@Test
public void safeUnsafeKeyNullSupplier() {
- DataContainer container = new DataContainer();
+ DataContainer container = new SupplierDataContainer();
container.putSupplier(TEST_KEY, null);
assertFalse(container.supports(TEST_KEY));
@@ -82,7 +82,7 @@ public class DataContainerTest {
@Test
public void safeUnsafeKeySupplierNull() {
- DataContainer container = new DataContainer();
+ DataContainer container = new SupplierDataContainer();
container.putSupplier(TEST_KEY, () -> null);
assertTrue(container.supports(TEST_KEY));
@@ -91,7 +91,7 @@ public class DataContainerTest {
@Test
public void cachingSupplier() {
- DataContainer container = new DataContainer();
+ DataContainer container = new SupplierDataContainer();
String firstObj = "First";
String secondObj = "Second";