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

com.github.charlemaznable.bunny.client.guice.AbstractBunnyModular Maven / Gradle / Ivy

Go to download

Bunny rabbits will skip hand-in-hand with baby lambs across sunny green meadows.

There is a newer version: 2023.0.4
Show newest version
package com.github.charlemaznable.bunny.client.guice;

import com.github.charlemaznable.bunny.client.config.BunnyClientConfig;
import com.github.charlemaznable.core.codec.nonsense.NonsenseOptions;
import com.github.charlemaznable.core.codec.signature.SignatureOptions;
import com.github.charlemaznable.core.guice.Modulee;
import com.github.charlemaznable.core.miner.MinerModular;
import com.google.inject.AbstractModule;
import com.google.inject.Module;
import com.google.inject.util.Providers;
import lombok.RequiredArgsConstructor;

@SuppressWarnings("unchecked")
@RequiredArgsConstructor
public abstract class AbstractBunnyModular {

    private final Module configModule;
    private NonsenseOptions nonsenseOptions;
    private SignatureOptions signatureOptions;

    public AbstractBunnyModular() {
        this((BunnyClientConfig) null);
    }

    public AbstractBunnyModular(Class configClass) {
        this(new MinerModular().bindClasses(configClass).createModule());
    }

    public AbstractBunnyModular(BunnyClientConfig configImpl) {
        this(new AbstractModule() {
            @Override
            protected void configure() {
                bind(BunnyClientConfig.class).toProvider(Providers.of(configImpl));
            }
        });
    }

    public T nonsenseOptions(NonsenseOptions nonsenseOptions) {
        this.nonsenseOptions = nonsenseOptions;
        return (T) this;
    }

    public T signatureOptions(SignatureOptions signatureOptions) {
        this.signatureOptions = signatureOptions;
        return (T) this;
    }

    public Module createModule() {
        return Modulee.override(new AbstractModule() {
            @Override
            protected void configure() {
                bind(NonsenseOptions.class).toProvider(Providers.of(nonsenseOptions));
                bind(SignatureOptions.class).toProvider(Providers.of(signatureOptions));
            }
        }, configModule);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy