Class Recyclable<T>

java.lang.Object
org.jpos.util.Recyclable<T>
Type Parameters:
T - the type of results supplied by this supplier
All Implemented Interfaces:
Supplier<T>

public class Recyclable<T> extends Object implements Supplier<T>
Caches a supplier's result up to approximately maxCycles.

After approximately maxCycles calls to its get() operation, Recyclable fetches a new result from its underlying Supplier.

Since:
2.1.3
  • Constructor Details

    • Recyclable

      public Recyclable(Supplier<T> supplier, long maxCycles)
      Constructs a Recyclable that delegates to supplier and rebuilds the wrapped object every maxCycles uses.
      Parameters:
      supplier - factory that produces fresh instances
      maxCycles - number of uses before the wrapped instance is replaced
  • Method Details