org.javabits.yar.guice.GuavaSupplierAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yar-guice Show documentation
Show all versions of yar-guice Show documentation
Yar Guice: provide a implementation / integration base on guice
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 extends T> 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