Package overit.geocall.util
Class DALazy<T>
java.lang.Object
overit.geocall.util.DALazy<T>
- All Implemented Interfaces:
Serializable,DAThrowingSupplier<T>
DALazy is a simple in-memory caching class.The
DALazy class suits the caching of database calls, complex object graph building routines, and web service calls that should be cached for performance.This implementation differs from
Lazy because it implements DAThrowingSupplier, and can therefore raise DAExceptions and DAValidateExceptions.- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDALazy()DALazy(DAThrowingSupplier<T> supplier) Creates aDALazyobject with the definedDAThrowingSupplier. -
Method Summary
Modifier and TypeMethodDescriptionfinal Tget()Returns the value, computing it from the supplier if necessary.final Tget(DAThrowingSupplier<T> supplier, T def) Returns the value retrieved from theDAThrowingSupplier.final TReturns the value, computing it from the supplier if necessary.
-
Field Details
-
supplier
-
value
-
-
Constructor Details
-
DALazy
public DALazy() -
DALazy
Creates aDALazyobject with the definedDAThrowingSupplier.- Parameters:
supplier-DAThrowingSupplierused to compute the value.
-
-
Method Details
-
get
Returns the value, computing it from the supplier if necessary.- Specified by:
getin interfaceDAThrowingSupplier<T>- Returns:
- the computed value.
- Throws:
DAException- if the supplier throws one.DAValidateException- if the supplier throws one.
-
get
Returns the value, computing it from the supplier if necessary. If the supplier returnsnull, returns the provided default.- Parameters:
def- the default value if supplier returnsnull.- Returns:
- the value or default.
- Throws:
DAException- if the supplier throws one.DAValidateException- if the supplier throws one.
-
get
Returns the value retrieved from theDAThrowingSupplier.- Parameters:
supplier- TheDAThrowingSupplier.def- The default value to return in case the value retrieved from theDAThrowingSupplierisnull.- Returns:
- The value retrieved from the
DAThrowingSupplier. - Throws:
DAValidateException- in case of db validation error.DAException- in case of db communication error.
-