Package org.opensaml.storage

# Class StorageRecord<Type>

java.lang.Object
org.opensaml.storage.StorageRecord<Type>

Type Parameters:
  `Type` - the object type represented by the record

Direct Known Subclasses:
  `MemcachedStorageRecord`, `MutableStorageRecord`

@NotThreadSafe public class StorageRecord<Type> extends Object
Represents a versioned record in a `StorageService`.

## Field Summary

Fields
Modifier and Type
Field
Description
`private Long`
`expiration`
Expiration field.
`private String`
`value`
Value field.
`private long`
`version`
Version field.

## Constructor Summary

Constructors
Constructor
Description
`StorageRecord(String val, Long exp)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`Long`
`getExpiration()`
Get the record expiration.
`String`
`getValue()`
Get the record value.
`Type`
`getValue(StorageSerializer<Type> serializer, String context, String key)`
Get the record value, using a custom deserialization process.
`long`
`getVersion()`
Get the record version.
`protected long`
`incrementVersion()`
Increment the record version and returns the new value.
`boolean`
`isExpired(long evalTime)`
Get whether the record has expired with respect to the supplied time.
`boolean`
`isValid(long evalTime)`
Get whether the record is valid with respect to the supplied time.
`protected void`
`setExpiration(Long exp)`
Set the record expiration.
`protected void`
`setValue(String val)`
Set the record value.
`protected void`
`setValue(Type instance, StorageSerializer<Type> serializer)`
Set the record value, using a custom serialization process.
`protected void`
`setVersion(long ver)`
Set the record version.

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

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

## Field Details

### version

private long version
Version field.

### value

@Nonnull @NotEmpty private String value
Value field.

### expiration

@Nullable private Long expiration
Expiration field.

## Constructor Details

### StorageRecord

public StorageRecord(@Nonnull @NotEmpty String val, @Nullable Long exp)
Constructor.

Parameters:
  `val` - value
  `exp` - expiration, or null if none

## Method Details

### getVersion

public long getVersion()
Get the record version.

Returns:
  the record version

### getValue

@Nonnull public String getValue()
Get the record value.

Returns:
  the record value

### getValue

@Nonnull public Type getValue(@Nonnull StorageSerializer<Type> serializer, @Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key) throws IOException
Get the record value, using a custom deserialization process.

Parameters:
  `serializer` - a custom (de)serialization process to apply
  `context` - context of record
  `key` - key of record
Returns:
  the record value
Throws:
  `IOException` - if deserialization fails

### getExpiration

@Nullable public Long getExpiration()
Get the record expiration.

Returns:
  the record expiration, or null if none

### isValid

public boolean isValid(long evalTime)
Get whether the record is valid with respect to the supplied time.

Parameters:
  `evalTime` - time to evaluate expiration against
Returns:
  true iff the record is non-expired
Since:
  5.0.0

### isExpired

public boolean isExpired(long evalTime)
Get whether the record has expired with respect to the supplied time.

Parameters:
  `evalTime` - time to evaluate expiration against
Returns:
  true iff the record is expired
Since:
  5.0.0

### setVersion

protected void setVersion(long ver)
Set the record version.

Parameters:
  `ver` - the new record version, must be > 0

### setValue

protected void setValue(@Nonnull @NotEmpty String val)
Set the record value.

Parameters:
  `val` - the new record value

### setValue

protected void setValue(@Nonnull Type instance, @Nonnull StorageSerializer<Type> serializer) throws IOException
Set the record value, using a custom serialization process.

Parameters:
  `instance` - the new record value
  `serializer` - a custom serialization process to apply
Throws:
  `IOException` - if serialization fails

### setExpiration

protected void setExpiration(@Nullable Long exp)
Set the record expiration.

Parameters:
  `exp` - the new record expiration, or null if none

### incrementVersion

protected long incrementVersion()
Increment the record version and returns the new value.

Returns:
  the updated version