net.sf.javagimmicks.util.LazySupplier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gimmicks Show documentation
Show all versions of gimmicks Show documentation
Utility classes, APIs and tools for Java
package net.sf.javagimmicks.util;
/**
* An implementation of {@link Supplier} that creates the instance when it is
* requested for the first time using an underlying {@link Supplier} which is
* commonly known as "lazy loading" pattern.
*
* @param
* the type of object the container can carry
*/
public class LazySupplier extends AbstractLazySupplier
{
private E _instance;
/**
* Creates a new instance for the given {@link Supplier}
*
* @param supplier
* the {@link Supplier} to use for creating the instance
*/
public LazySupplier(final Supplier supplier)
{
super(supplier);
}
@Override
protected E getInstance()
{
return _instance;
}
@Override
protected void setInstance(final E instance)
{
_instance = instance;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy