Search in sources :

Example 11 with DataContainer

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));
}
Also used : SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer) DataContainer(com.djrapitops.plan.delivery.domain.container.DataContainer) SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer) Test(org.junit.jupiter.api.Test)

Example 12 with DataContainer

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));
}
Also used : SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer) DataContainer(com.djrapitops.plan.delivery.domain.container.DataContainer) SupplierDataContainer(com.djrapitops.plan.delivery.domain.container.SupplierDataContainer) Test(org.junit.jupiter.api.Test)

Example 13 with DataContainer

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);
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) DataContainer(com.djrapitops.plan.delivery.domain.container.DataContainer)

Example 14 with DataContainer

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);
}
Also used : DataContainer(com.djrapitops.plan.delivery.domain.container.DataContainer)

Aggregations

DataContainer (com.djrapitops.plan.delivery.domain.container.DataContainer)14 SupplierDataContainer (com.djrapitops.plan.delivery.domain.container.SupplierDataContainer)9 Test (org.junit.jupiter.api.Test)8 ServerUUID (com.djrapitops.plan.identification.ServerUUID)4 WorldTimes (com.djrapitops.plan.gathering.domain.WorldTimes)3 Map (java.util.Map)2 PerServerContainer (com.djrapitops.plan.delivery.domain.container.PerServerContainer)1 SessionsMutator (com.djrapitops.plan.delivery.domain.mutators.SessionsMutator)1 WorldPie (com.djrapitops.plan.delivery.rendering.json.graphs.pie.WorldPie)1 FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1