|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
T
- The value type.@Copyright(value="Copyright © 2008, Iparelan Solutions, LLC. All rights reserved.") public interface ImmutabilityStrategy<T>
An algorithm for guarding a specified value with respect to value changes. This strategy ensures that nothing can accidentally or maliciously alter a value through the value produced by the strategy.
Note that this strategy does not necessarily produce immutable objects. Rather, it produces objects that cannot mutate the objects passed to it. For example, producing a mutable copy is sufficient to guard the original object from change (via the mutable copy).
There are three cases to consider:
The particular manner in which this operation is done depends on the type being copied. Some types support a clone operation, others have a copy constructor, but some types have no support for the Prototype pattern. In such cases, custom copying code must be written to adapt the type for copying.
Note that this approach will most likely "unlink" the copy from from the original. This is important if the original is not "totally immutable," in other words, if the original object may be changed elsewhere. Such a change will not be reflected in the copy unless some update mechanism is created to link the original to all copies of it.
The clone is produced instead of the object that holds the immutable value.
The decorator is produced instead of the object that holds the "immutable" value.
Field Summary | |
---|---|
static ImmutabilityStrategy<Integer> |
INTEGER
|
Method Summary | |
---|---|
T |
freeze(T immutable)
Produces the same value as immutable , but the value produced does
not have the capability of changing immutable . |
Field Detail |
---|
static final ImmutabilityStrategy<Integer> INTEGER
Method Detail |
---|
@Nullable T freeze(@Nullable T immutable)
immutable
, but the value produced does
not have the capability of changing immutable
. Note that this is
slightly different than ensuring that the value immutable
may
never change.
immutable
- A value that may not be altered by the value produced by this
method. May be null
.
immutable
, but without the capability
of changing immutable
. null
iff immutable
is null
. The value produce may or may not be the same
object as immutable
.
ConfigurationException
- Iff some error occurs while attempting to protect the integrity
of immutable
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |