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

org.javabits.yar.guice.GuavaSupplierAdapter Maven / Gradle / Ivy

There is a newer version: 3.0.1.RELEASE
Show newest version
package org.javabits.yar.guice;

import org.javabits.yar.Id;
import org.javabits.yar.Supplier;

import javax.annotation.Nullable;

import static java.util.Objects.requireNonNull;

/**
 * TODO comment
 * Date: 5/3/13
 * Time: 6:08 AM
 *
 * @author Romain Gilles
 */
class GuavaSupplierAdapter implements Supplier, SupplierWrapper {
    private final com.google.common.base.Supplier delegate;
    private final Id id;

    GuavaSupplierAdapter(Id id, com.google.common.base.Supplier delegate) {
        this.id = requireNonNull(id, "id");
        this.delegate = (com.google.common.base.Supplier) requireNonNull(delegate, "delegate");
    }

    @Override
    public Id id() {
        return id;
    }

    @Nullable
    @Override
    public T get() {
        return delegate.get();
    }

    @Override
    public String toString() {
        return "GuavaSupplierAdapter{" +
                "delegate=" + delegate +
                ", id=" + id +
                '}';
    }

    @Nullable
    @Override
    public com.google.common.base.Supplier getNativeSupplier() {
        return delegate;
    }

    @Override
    public com.google.common.base.Supplier getWrapped() {
        return getNativeSupplier();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy