Class SetOnce<T>
A convenient class which offers a semi-immutable object wrapper implementation which allows one to set the value of an object exactly once, and retrieve it many times. If Set(T) is called more than once, AlreadySetException is thrown and the operation will fail.
Note
This API is experimental and might change in incompatible ways in the next release.
Inherited Members
Namespace: Lucene.Net.Util
Assembly: Lucene.Net.dll
Syntax
public sealed class SetOnce<T> where T : class
Type Parameters
Name | Description |
---|---|
T |
Constructors
SetOnce()
A default constructor which does not set the internal object, and allows setting it by calling Set(T).
Declaration
public SetOnce()
SetOnce(T)
Creates a new instance with the internal object set to the given object. Note that any calls to Set(T) afterwards will result in AlreadySetException
Declaration
public SetOnce(T obj)
Parameters
Type | Name | Description |
---|---|---|
T | obj |
Exceptions
Type | Condition |
---|---|
AlreadySetException | if called more than once |
See Also
Methods
Clone()
A convenient class which offers a semi-immutable object wrapper implementation which allows one to set the value of an object exactly once, and retrieve it many times. If Set(T) is called more than once, AlreadySetException is thrown and the operation will fail.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public object Clone()
Returns
Type | Description |
---|---|
object |
Get()
Returns the object set by Set(T).
Declaration
public T Get()
Returns
Type | Description |
---|---|
T |
Set(T)
Sets the given object. If the object has already been set, an exception is thrown.
Declaration
public void Set(T obj)
Parameters
Type | Name | Description |
---|---|---|
T | obj |