All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jdash.client.response.UserStatsListResponseDeserializer Maven / Gradle / Ivy

The newest version!
package jdash.client.response;

import jdash.client.exception.ActionFailedException;
import jdash.common.entity.GDUserStats;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

import static jdash.common.internal.InternalUtils.buildUserStats;
import static jdash.common.internal.InternalUtils.splitToMap;

class UserStatsListResponseDeserializer implements Function> {

    @Override
    public List apply(String response) {
        ActionFailedException.throwIfEquals(response, "-1", "Failed to load user(s)");
        final var list = new ArrayList();
        final var users = response.split("#")[0].split("\\|");
        for (String user : users) {
            list.add(buildUserStats(splitToMap(user, ":")));
        }
        return list;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy