use of com.djrapitops.plan.delivery.domain.container.DataContainer in project Plan by plan-player-analytics.
the class SupplierDataContainerTest method safeUnsafeKeySupplierNull.
@Test
void safeUnsafeKeySupplierNull() {
DataContainer container = new SupplierDataContainer();
container.putSupplier(TEST_KEY, () -> null);
assertTrue(container.supports(TEST_KEY));
assertNull(container.getUnsafe(TEST_KEY));
}
use of com.djrapitops.plan.delivery.domain.container.DataContainer in project Plan by plan-player-analytics.
the class SupplierDataContainerTest method safeUnsafeKeySupplierSameObject.
@Test
void safeUnsafeKeySupplierSameObject() {
DataContainer container = new SupplierDataContainer();
container.putSupplier(TEST_KEY, () -> "Success");
assertEquals("Success", container.getUnsafe(TEST_KEY));
}
use of com.djrapitops.plan.delivery.domain.container.DataContainer in project Plan by plan-player-analytics.
the class PerServerMutator method favoriteServer.
public Optional<ServerUUID> favoriteServer() {
long max = 0;
ServerUUID maxServer = null;
for (Map.Entry<ServerUUID, DataContainer> entry : data.entrySet()) {
long total = SessionsMutator.forContainer(entry.getValue()).toPlaytime();
if (total > max) {
max = total;
maxServer = entry.getKey();
}
}
return Optional.ofNullable(maxServer);
}
use of com.djrapitops.plan.delivery.domain.container.DataContainer in project Plan by plan-player-analytics.
the class PerServerMutator method latestJoinAddress.
public Optional<String> latestJoinAddress() {
long latest = Long.MIN_VALUE;
String latestJoinAddress = null;
for (DataContainer value : data.values()) {
long registerDate = value.getValue(PerServerKeys.REGISTERED).orElse(Long.MIN_VALUE);
Optional<String> joinAddress = value.getValue(PerServerKeys.JOIN_ADDRESS);
if (registerDate > latest && joinAddress.isPresent()) {
latest = registerDate;
latestJoinAddress = joinAddress.get();
}
}
return Optional.ofNullable(latestJoinAddress);
}
Aggregations