Module jtrim.query

Class CachedLinkRequest<QueryArgType>

java.lang.Object
org.jtrim2.concurrent.query.CachedLinkRequest<QueryArgType>
Type Parameters:
QueryArgType - the type of the actual input of the query for the data retrieval process. Note that this type is recommended to be immutable or effectively immutable.

public final class CachedLinkRequest<QueryArgType> extends Object
Defines a request for a data when the AsyncDataLink providing should be cached. The request is intended to passed to an AsyncDataQuery as an input.

Apart from the input of the query, the request contains an timeout value after the cached AsyncDataLink becomes invalid and should be recreated when needed again.

Thread safety

The methods of this class are safe to be accessed by multiple threads concurrently. Instances of this class are immutable except that the actual input of the query can possibly be mutable. Note however that it is recommended that this input be immutable as well making instances of this class completely immutable.

Synchronization transparency

The methods of this class are synchronization transparent.
See Also:
  • Constructor Details

    • CachedLinkRequest

      public CachedLinkRequest(QueryArgType queryArg)
      Creates and initializes the CachedLinkRequest with the given input for the query and one hour as the cache expire timeout value.
      Parameters:
      queryArg - the object used as the input of the AsyncDataQuery to retrieve the requested data. This argument can be null if the query accepts null values as its input.
    • CachedLinkRequest

      public CachedLinkRequest(QueryArgType queryArg, long cacheExpire, TimeUnit timeunit)
      Creates and initializes the CachedLinkRequest with the given input for the query and the cache expire timeout value.
      Parameters:
      queryArg - the object used as the input of the AsyncDataQuery to retrieve the requested data. This argument can be null if the query accepts null values as its input.
      cacheExpire - the time in the given unit after the AsyncDataLink instance created using this request becomes invalid and should be recreated. This argument must be greater than or equal to zero.
      timeunit - the time unit of the cacheExpire argument. This argument cannot be null.
      Throws:
      IllegalArgumentException - thrown if cacheExpire < 0
      NullPointerException - thrown if timeunit is null
  • Method Details

    • getCacheExpire

      public long getCacheExpire(TimeUnit timeunit)
      Returns the timeout value in the given time unit after an AsyncDataLink requested by this request becomes invalid and must be recreated.
      Parameters:
      timeunit - the time unit in which the timeout value is to be returned. This argument cannot be null.
      Returns:
      the timeout value in the given time unit after an AsyncDataLink requested by this request becomes invalid and must be recreated. This method always returns a value greater than or equal to zero.
    • getQueryArg

      public QueryArgType getQueryArg()
      Returns the object used as the input of the query of the data. That is, this is the only property which determines what data is to be retrieved.
      Returns:
      the object used as the input of the query of the data. This method may return null if null was passed in the constructor.
    • toString

      public String toString()
      Returns the string representation of this CachedLinkRequest in no particular format.

      This method is intended to be used for debugging only.

      Overrides:
      toString in class Object
      Returns:
      the string representation of this object in no particular format. This method never returns null.