io.github.qsy7.print.providers.cups4j.CupsClientProvider Maven / Gradle / Ivy
The newest version!
package io.github.qsy7.print.providers.cups4j;
import io.github.qsy7.print.providers.cups4j.property.CupsPassword;
import io.github.qsy7.print.providers.cups4j.property.CupsPort;
import io.github.qsy7.print.providers.cups4j.property.CupsServer;
import io.github.qsy7.print.providers.cups4j.property.CupsUser;
import io.github.qsy7.property.api.annotation.Property;
import jakarta.inject.Inject;
import jakarta.inject.Provider;
import org.cups4j.CupsClient;
public class CupsClientProvider implements Provider {
protected final CupsClient cupsClient;
@Inject
public CupsClientProvider(
@Property(CupsPort.class) int cupsPort,
@Property(CupsServer.class) String cupsServer,
@Property(CupsUser.class) String cupsUser,
@Property(CupsPassword.class) String cupsPassword)
throws Exception {
if (cupsUser != null) this.cupsClient = new CupsClient(cupsServer, cupsPort, cupsUser);
else this.cupsClient = new CupsClient(cupsServer, cupsPort);
}
@Override
public CupsClient get() {
return cupsClient;
}
}