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

com.github.charlemaznable.varys.impl.VarysProxyShansongAppMerchantUrlProvider Maven / Gradle / Ivy

package com.github.charlemaznable.varys.impl;

import com.github.charlemaznable.httpclient.common.Mapping.UrlProvider;
import com.github.charlemaznable.varys.config.VarysConfig;
import com.google.inject.Inject;
import lombok.val;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Nullable;

import static com.github.charlemaznable.configservice.ConfigFactory.getConfig;
import static com.github.charlemaznable.core.lang.Condition.checkNotNull;
import static com.github.charlemaznable.core.lang.Condition.nullThen;
import static org.apache.commons.lang3.StringUtils.appendIfMissing;

@Component
public final class VarysProxyShansongAppMerchantUrlProvider implements UrlProvider {

    private final VarysConfig varysConfig;

    public VarysProxyShansongAppMerchantUrlProvider() {
        this(null);
    }

    @Inject
    @Autowired
    public VarysProxyShansongAppMerchantUrlProvider(@Nullable VarysConfig varysConfig) {
        this.varysConfig = nullThen(varysConfig, () -> getConfig(VarysConfig.class));
    }

    @Override
    public String url(Class clazz) {
        val address = checkNotNull(varysConfig.address());
        return appendIfMissing(address, "/") + "proxy-shansong-app-merchant";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy