Package org.opensaml.core.xml.persist

# Class AbstractConditionalLoadXMLObjectLoadSaveManager<T extends XMLObject>

java.lang.Object
org.opensaml.core.xml.persist.AbstractConditionalLoadXMLObjectLoadSaveManager<T>

Type Parameters:
  `T` - the base type of XML objects being managed

All Implemented Interfaces:
  `ConditionalLoadXMLObjectLoadSaveManager<T>`, `XMLObjectLoadSaveManager<T>`

Direct Known Subclasses:
  `FilesystemLoadSaveManager`, `MapLoadSaveManager`

public abstract class AbstractConditionalLoadXMLObjectLoadSaveManager<T extends XMLObject> extends Object implements ConditionalLoadXMLObjectLoadSaveManager<T>
Abstract base class for `XMLObjectLoadSaveManager` implementations which track the modify times of requested data such that `XMLObjectLoadSaveManager.load(String)` returns data only if the data associated with the key has been modified since the last request.

## Field Summary

Fields
Modifier and Type
Field
Description
`private boolean`
`loadConditionally`
Configuration flag for whether `XMLObjectLoadSaveManager.load(String)` will check and return data only if modified since the last request for that data.
`private Map<String,Instant>`
`loadLastModified`
Storage for last modified time of requested data.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`AbstractConditionalLoadXMLObjectLoadSaveManager(boolean conditionalLoad)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`clearAllLoadLastModified()`
Clear the cached modified times for the last load for all keys.
`Instant`
`clearLoadLastModified(String key)`
Clear the cached modified time for the last load of the specified key.
`Instant`
`getLoadLastModified(String key)`
Retrieve the cached modified time for the last load of the specified key.
`boolean`
`isLoadConditionally()`
Get whether `XMLObjectLoadSaveManager.load(String)` will check and return data only if modified since the last request for that data.
`protected abstract boolean`
`isUnmodifiedSinceLastLoad(String key)`
Check whether the data corresponding to the specified key has been modified since the last time `XMLObjectLoadSaveManager.load(String)` was called for that key.
`protected Instant`
`updateLoadLastModified(String key)`
Update the cached modified time for the specified key with the current time.
`protected Instant`
`updateLoadLastModified(String key, Instant modified)`
Update the cached modified time for the specified key with the specified time.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.opensaml.core.xml.persist.XMLObjectLoadSaveManager

`exists, listAll, listKeys, load, remove, save, save, updateKey`

## Field Details

### loadConditionally

private boolean loadConditionally
Configuration flag for whether `XMLObjectLoadSaveManager.load(String)` will check and return data only if modified since the last request for that data.

### loadLastModified

@Nonnull private Map<String,Instant> loadLastModified
Storage for last modified time of requested data.

## Constructor Details

### AbstractConditionalLoadXMLObjectLoadSaveManager

protected AbstractConditionalLoadXMLObjectLoadSaveManager(@ParameterName(name="conditionalLoad") boolean conditionalLoad)
Constructor.

Parameters:
  `conditionalLoad` - whether `XMLObjectLoadSaveManager.load(String)` should behave as defined in `ConditionalLoadXMLObjectLoadSaveManager`

## Method Details

### isLoadConditionally

public boolean isLoadConditionally()
Get whether `XMLObjectLoadSaveManager.load(String)` will check and return data only if modified since the last request for that data.

Specified by:
  `isLoadConditionally` in interface `ConditionalLoadXMLObjectLoadSaveManager<T extends XMLObject>`
Returns:
  true if data modify time check is enabled, false if not

### getLoadLastModified

@Nullable public Instant getLoadLastModified(@Nonnull String key)
Retrieve the cached modified time for the last load of the specified key.

Note that this will be null if `XMLObjectLoadSaveManager.load(String)` has not been called for the specified key since construction or since the last call to `ConditionalLoadXMLObjectLoadSaveManager.clearLoadLastModified(String)` or `ConditionalLoadXMLObjectLoadSaveManager.clearAllLoadLastModified()`.

Specified by:
  `getLoadLastModified` in interface `ConditionalLoadXMLObjectLoadSaveManager<T extends XMLObject>`
Parameters:
  `key` - the target key
Returns:
  the current cached modified time, may be null

### clearLoadLastModified

@Nullable public Instant clearLoadLastModified(@Nonnull String key)
Clear the cached modified time for the last load of the specified key.

Specified by:
  `clearLoadLastModified` in interface `ConditionalLoadXMLObjectLoadSaveManager<T extends XMLObject>`
Parameters:
  `key` - the target key
Returns:
  the previously cached modified time, or null if did not exist

### clearAllLoadLastModified

public void clearAllLoadLastModified()
Clear the cached modified times for the last load for all keys.

Specified by:
  `clearAllLoadLastModified` in interface `ConditionalLoadXMLObjectLoadSaveManager<T extends XMLObject>`

### updateLoadLastModified

protected Instant updateLoadLastModified(@Nonnull String key)
Update the cached modified time for the specified key with the current time.

Parameters:
  `key` - the target key
Returns:
  the previously cached modified time, or null if did not exist

### updateLoadLastModified

@Nullable protected Instant updateLoadLastModified(@Nonnull String key, @Nullable Instant modified)
Update the cached modified time for the specified key with the specified time.

Parameters:
  `key` - the target key
  `modified` - the new cached modified time
Returns:
  the previously cached modified time, or null if did not exist

### isUnmodifiedSinceLastLoad

protected abstract boolean isUnmodifiedSinceLastLoad(@Nonnull String key) throws IOException
Check whether the data corresponding to the specified key has been modified since the last time `XMLObjectLoadSaveManager.load(String)` was called for that key.

Parameters:
  `key` - the data key
Returns:
  true if the corresponding data has been modified since the last load, false otherwise
Throws:
  `IOException` - if there is a fatal error evaluating the last modified status