com.github.charlemaznable.varys.impl.VarysProxyWechatAppUrlProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of varys-java-driver Show documentation
Show all versions of varys-java-driver Show documentation
Java client for varys(https://github.com/CharLemAznable/varys).
package com.github.charlemaznable.varys.impl;
import com.github.charlemaznable.core.net.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.core.lang.Condition.checkNotNull;
import static com.github.charlemaznable.core.lang.Condition.nullThen;
import static com.github.charlemaznable.core.miner.MinerFactory.getMiner;
import static org.apache.commons.lang3.StringUtils.appendIfMissing;
@Component
public final class VarysProxyWechatAppUrlProvider implements UrlProvider {
private final VarysConfig varysConfig;
public VarysProxyWechatAppUrlProvider() {
this(null);
}
@Inject
@Autowired
public VarysProxyWechatAppUrlProvider(@Nullable VarysConfig varysConfig) {
this.varysConfig = nullThen(varysConfig, () -> getMiner(VarysConfig.class));
}
@Override
public String url(Class> clazz) {
val address = checkNotNull(varysConfig.address());
return appendIfMissing(address, "/") + "proxy-wechat-app";
}
}