Dart Documentationclean_dataChange

Change class

A representation of a single change in a scalar value.

class Change {
 dynamic oldValue;
 dynamic newValue;

 get isEmpty {
   return oldValue == unset && newValue == unset;
 }

 /**
  * Creates new [Change] from information about the value before change
  * [oldValue] and after the change [newValue].
  */
 Change([this.oldValue = unset, this.newValue = unset]){
   assert(oldValue is! DataReference);
   assert(newValue is! DataReference);
 }

 bool equals(dynamic other) {
   if (other is Change){
     return oldValue == other.oldValue &&
            newValue == other.newValue;
   } else {
     return false;
   }
 }

 /**
  * Applies another [change] to get representation of whole change.
  */
 void mergeIn(Change change) {
   if (change.isEmpty) {
     return;
   }
   assert(isEmpty || change.oldValue == this.newValue);
   if (isEmpty) {
     oldValue = change.oldValue;
   }
   newValue = change.newValue;
 }

 /**
  * Clones the [change].
  */
 Change clone() {
   return new Change(oldValue, newValue);
 }

 String toString() => "Change($oldValue->$newValue)";

}

Constructors

new Change([oldValue = unset, newValue = unset]) #

Creates new Change from information about the value before change oldValue and after the change newValue.

Change([this.oldValue = unset, this.newValue = unset]){
 assert(oldValue is! DataReference);
 assert(newValue is! DataReference);
}

Properties

final isEmpty #

get isEmpty {
 return oldValue == unset && newValue == unset;
}

var newValue #

dynamic newValue

var oldValue #

dynamic oldValue

Methods

Change clone() #

Clones the change.

Change clone() {
 return new Change(oldValue, newValue);
}

bool equals(other) #

bool equals(dynamic other) {
 if (other is Change){
   return oldValue == other.oldValue &&
          newValue == other.newValue;
 } else {
   return false;
 }
}

void mergeIn(Change change) #

Applies another change to get representation of whole change.

void mergeIn(Change change) {
 if (change.isEmpty) {
   return;
 }
 assert(isEmpty || change.oldValue == this.newValue);
 if (isEmpty) {
   oldValue = change.oldValue;
 }
 newValue = change.newValue;
}

String toString() #

Returns a string representation of this object.

docs inherited from Object
String toString() => "Change($oldValue->$newValue)";