Package com.storedobject.common
Interface ComputedValue<T>
- Type Parameters:
T- the type of the value managed by this interface
- All Superinterfaces:
Cloneable,Displayable
- All Known Implementing Classes:
AbstractComputedInteger,AbstractComputedValue,ComputedDate,ComputedDouble,ComputedInteger,ComputedLong,ComputedMinute
The
ComputedValue interface represents a value that supports computational
state, providing mechanisms to check and modify whether the value is computed or
manually set. It extends the Cloneable interface to allow object cloning
and the Displayable interface for a displayable representation of the value.- Author:
- Syam
-
Method Summary
Modifier and TypeMethodDescriptionclone()Creates and returns a copy of thisComputedValueinstance.default booleanconsider()Evaluates the current state of the value to determine whether it is not in a computed state.default voidconsider(boolean consider) Sets the computed state of the value based on the provided consideration.default voidenable(boolean enable) Enables or disables a certain state by changing the computed state of the value.Retrieves the value object associated with this instance.default booleanignore()Checks whether the current value should be ignored based on its computed state.default voidignore(boolean ignore) Sets the computed state of the value based on the provided ignore flag.booleanDetermines whether the current value is in a computed state.default booleanisManual()Determines whether the current value is set manually.default voidReverses the state of the current value based on its ignore status.voidsetComputed(boolean computed) Sets the computed state of the value.default voidsetManual(boolean manual) Sets the manual state of the value.voidSets the value for the current instance.Methods inherited from interface com.storedobject.common.Displayable
toDisplay
-
Method Details
-
isComputed
boolean isComputed()Determines whether the current value is in a computed state.- Returns:
trueif the value is computed,falseif it is manually set or not computed.
-
setComputed
void setComputed(boolean computed) Sets the computed state of the value.- Parameters:
computed- iftrue, marks the value as computed; iffalse, marks the value as manually set or non-computed.
-
isManual
default boolean isManual()Determines whether the current value is set manually.- Returns:
trueif the value is manually set,falseif it is in a computed state.
-
consider
default boolean consider()Evaluates the current state of the value to determine whether it is not in a computed state.- Returns:
trueif the value is not computed (i.e., manually set or non-computed),falseotherwise.
-
consider
default void consider(boolean consider) Sets the computed state of the value based on the provided consideration. Ifconsideristrue, the computed state is set tofalse, indicating a manual state. Ifconsiderisfalse, the computed state is set totrue.- Parameters:
consider-trueto mark the value as not computed (manually set),falseto mark it as computed.
-
ignore
default boolean ignore()Checks whether the current value should be ignored based on its computed state.- Returns:
trueif the value is in a computed state and should be ignored;falseif it is not computed and should not be ignored.
-
ignore
default void ignore(boolean ignore) Sets the computed state of the value based on the provided ignore flag. Ifignoreistrue, the computed state is set totrue, marking the value as computed. Ifignoreisfalse, the computed state is set tofalse, marking the value as manually set or non-computed.- Parameters:
ignore-trueto mark the value as computed and ignored;falseto mark it as manually set and not ignored.
-
setManual
default void setManual(boolean manual) Sets the manual state of the value. When the value is set to manual, its computed state is automatically negated.- Parameters:
manual-trueto mark the value as manually set,falseto mark it as in a computed state.
-
enable
default void enable(boolean enable) Enables or disables a certain state by changing the computed state of the value. If theenableparameter istrue, the computed state is set tofalse. If theenableparameter isfalse, the computed state is set totrue.- Parameters:
enable-trueto enable the state by setting the value as not computed;falseto disable the state by setting the value as computed.
-
reverseStatus
default void reverseStatus()Reverses the state of the current value based on its ignore status. If the value is currently ignored (computed state), it updates the state to be considered (not computed). Otherwise, it updates the state to be ignored (computed). -
setValue
Sets the value for the current instance. The provided value may be manually set or used in conjunction with the computed state of the object, depending on other methods and logic in the class.- Parameters:
value- the value to be set for the current instance
-
getValueObject
T getValueObject()Retrieves the value object associated with this instance.- Returns:
- the value object of type
T.
-
clone
Creates and returns a copy of thisComputedValueinstance. The cloned object is a new instance identical to the original, maintaining the same state and value.- Returns:
- a new
ComputedValue<T>instance that is a copy of the current object - Throws:
CloneNotSupportedException- if the object's class does not support cloning
-