io.github.factoryfx.microservice.rest.client.MicroserviceRestClientBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of microserviceRestClient Show documentation
Show all versions of microserviceRestClient Show documentation
factoryfx dependency injection framework
The newest version!
package io.github.factoryfx.microservice.rest.client;
import io.github.factoryfx.factory.FactoryBase;
import io.github.factoryfx.server.user.persistent.PasswordHash;
public class MicroserviceRestClientBuilder {
/**
* For user management
* @param host host
* @param port port
* @param user user
* @param passwordNotHashed password in clear text
* @param serverRootClass server class, cause type erasure
* @param Root client
* @param Root Server
* @return client
*/
public static , RS extends FactoryBase,RS>> MicroserviceRestClient build(String host, int port, String user, String passwordNotHashed, Class serverRootClass){
MicroserviceRestClientFactory microserviceRestClientFactory = new MicroserviceRestClientFactory<>();
microserviceRestClientFactory.port.set(port);
microserviceRestClientFactory.host.set(host);
microserviceRestClientFactory.user.set(user);
microserviceRestClientFactory.passwordHash.set(new PasswordHash().hash(passwordNotHashed));
return microserviceRestClientFactory.createClient();
}
/**
* For no user management
* @param host host
* @param port port
* @param serverRootClass server class, cause type erasure
* @param Root client
* @param Root Server
* @return client
*/
public static , RS extends FactoryBase,RS>> MicroserviceRestClient build(String host, int port, Class serverRootClass){
MicroserviceRestClientFactory microserviceRestClientFactory = new MicroserviceRestClientFactory<>();
microserviceRestClientFactory.port.set(port);
microserviceRestClientFactory.host.set(host);
microserviceRestClientFactory.user.set(null);
microserviceRestClientFactory.passwordHash.set(null);
return microserviceRestClientFactory.createClient();
}
}