java.lang.Object
com.tccc.kos.commons.core.service.config.ValPair
Direct Known Subclasses:
BeanChanges.AttrChange

public class ValPair extends Object
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 Details

    • ValPair

      public ValPair()
      Constructs a new instance in which both data fields are null.
    • ValPair

      public ValPair(String currentValue, String previousValue)
      Constructs a new instance using the specified values.
      Parameters:
      currentValue - the current value
      previousValue - the previous value
  • Method Details

    • getCurrentValue

      public String getCurrentValue()
      Retrieves the current value.
      Returns:
      the current value
    • setCurrentValue

      public void setCurrentValue(String currentValue)
      Sets the current value.
      Parameters:
      currentValue - the value to set
    • getPreviousValue

      public String getPreviousValue()
      Retrieves the previous value.
      Returns:
      the previous value
    • setPreviousValue

      public void setPreviousValue(String previousValue)
      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, otherwise false if they are equal
    • toString

      public String toString()
      Returns the string representation of this object.
      Overrides:
      toString in class Object
      Returns:
      string representation of this object