com.liferay.faces.util.lang
Class ThreadSafeAccessor<T,X>
java.lang.Object
com.liferay.faces.util.lang.ThreadSafeAccessor<T,X>
- Type Parameters:
T - The type that will be returned from the get(java.lang.Object) and computeValue(java.lang.Object) methods.X - The type of argument that will be passed to the get(java.lang.Object) and computeValue(java.lang.Object) methods in order to initialize the ThreadSafeAccessor value.
public abstract class ThreadSafeAccessor<T,X>
- extends Object
This class represents a lazily initialized, effectively immutable value. The value is initialized in a thread-safe
way such that computeValue(java.lang.Object) is only called once by a single thread.
- Author:
- Kyle Stiemann
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ThreadSafeAccessor
public ThreadSafeAccessor()
get
public final T get(X arg)
- Returns the
ThreadSafeAccessor value. The value is lazily initialized by the first thread that attempts
to access it.
- Parameters:
arg - The argument needed to initialize the ThreadSafeAccessor value.
computeValue
protected abstract T computeValue(X args)
- Returns the initial value of the
ThreadSafeAccessor. This method will only be called once by a single
thread to obtain the initial value. Subclasses must override this method to provide the process necessary to
compute the initial value of the ThreadSafeAccessor.
- Parameters:
args - The argument needed to initialize the ThreadSafeAccessor value.
Copyright © 2019 Liferay, Inc.. All rights reserved.