Class ValPair
java.lang.Object
com.tccc.kos.commons.core.service.config.ValPair
- Direct Known Subclasses:
BeanChanges.AttrChange
Data class used track a current or new value verses a previous value.
It is used to determine if a particular value has changed or not. This is
typically used in the configuration system, which monitors if
settings become modified.
Data Fields
private String currentValue;
private String previousValue;
Example
ValPair valPair = new ValPair("bar", "bar");
assertThat(valPair.hasChanged(), equalTo(false));
valPair.setCurrentValue("foo");
assertThat(valPair.hasChanged(), equalTo(true));
assertThat(valPair.toString(), equalTo("ValPair[currentValue=foo, previousValue=bar]"));
- Since:
- 1.0
- Version:
- 2022-08-30
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the current value.Retrieves the previous value.boolean
Returns true if the current and previous values are different.void
setCurrentValue
(String currentValue) Sets the current value.void
setPreviousValue
(String previousValue) Sets the previous value.toString()
Returns the string representation of this object.
-
Constructor Details
-
ValPair
public ValPair()Constructs a new instance in which both data fields are null. -
ValPair
Constructs a new instance using the specified values.- Parameters:
currentValue
- the current valuepreviousValue
- the previous value
-
-
Method Details
-
getCurrentValue
Retrieves the current value.- Returns:
- the current value
-
setCurrentValue
Sets the current value.- Parameters:
currentValue
- the value to set
-
getPreviousValue
Retrieves the previous value.- Returns:
- the previous value
-
setPreviousValue
Sets the previous value.- Parameters:
previousValue
- the previous value
-
hasChanged
public boolean hasChanged()Returns true if the current and previous values are different.- Returns:
true
if the value has changed, otherwisefalse
if they are equal
-
toString
Returns the string representation of this object.
-