gitlab.com/evatix-go/core@v1.3.55/errcore/CountStateChangeTracker.go (about)

     1  package errcore
     2  
     3  type CountStateChangeTracker struct {
     4  	lengthGetter
     5  	initLength int
     6  }
     7  
     8  func NewCountStateChangeTracker(
     9  	lengthGetter lengthGetter,
    10  ) CountStateChangeTracker {
    11  	return CountStateChangeTracker{
    12  		lengthGetter: lengthGetter,
    13  		initLength:   lengthGetter.Length(),
    14  	}
    15  }
    16  
    17  func (it CountStateChangeTracker) IsSameStateUsingCount(
    18  	currentCount int,
    19  ) bool {
    20  	return currentCount == it.initLength
    21  }
    22  
    23  func (it CountStateChangeTracker) IsSameState() bool {
    24  	return it.lengthGetter.Length() == it.initLength
    25  }
    26  
    27  func (it CountStateChangeTracker) IsValid() bool {
    28  	return it.lengthGetter.Length() == it.initLength
    29  }
    30  
    31  func (it CountStateChangeTracker) IsSuccess() bool {
    32  	return it.lengthGetter.Length() == it.initLength
    33  }
    34  
    35  func (it CountStateChangeTracker) IsFailed() bool {
    36  	return it.lengthGetter.Length() != it.initLength
    37  }
    38  
    39  func (it CountStateChangeTracker) HasChanges() bool {
    40  	return it.lengthGetter.Length() != it.initLength
    41  }