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

io.mstream.trader.commons.http.parameter.ParametersFactory Maven / Gradle / Ivy

The newest version!
package io.mstream.trader.commons.http.parameter;

import ratpack.handling.Context;

import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import static io.mstream.trader.commons.utils.Preconditions.checkNotNull;


public class ParametersFactory {

    public Parameters create(Context context) {

        checkNotNull("context", context);

        Map parameters =
                context.getPathTokens().entrySet().stream()
                        .map(entry -> new Parameter(
                                entry.getKey(),
                                entry.getValue()
                        ))
                        .collect(Collectors.toMap(
                                Parameter::getName,
                                Function.identity()
                        ));

        return new Parameters(parameters);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy