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

com.github.charlemaznable.bunny.client.ohclient.BunnyOhClientUrlProvider Maven / Gradle / Ivy

package com.github.charlemaznable.bunny.client.ohclient;

import com.github.charlemaznable.bunny.client.config.BunnyClientConfig;
import com.github.charlemaznable.core.net.common.Mapping.UrlProvider;
import com.google.inject.Inject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Nullable;

import static com.github.charlemaznable.core.lang.Condition.checkNotNull;
import static com.github.charlemaznable.core.lang.Condition.nullThen;
import static com.github.charlemaznable.core.miner.MinerFactory.getMiner;

@Component
public final class BunnyOhClientUrlProvider implements UrlProvider {

    private final BunnyClientConfig bunnyClientConfig;

    @Inject
    @Autowired
    public BunnyOhClientUrlProvider(@Nullable BunnyClientConfig bunnyClientConfig) {
        this.bunnyClientConfig = nullThen(bunnyClientConfig,
                () -> getMiner(BunnyClientConfig.class));
    }

    @Override
    public String url(Class clazz) {
        return checkNotNull(bunnyClientConfig.httpServerBaseUrl());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy