Skip to content
Snippets Groups Projects
Select Git revision
  • feature/v1.3.60
  • develop default protected
  • main protected
  • release/v1.0.7
  • release/v1.0.0
  • feature/v0.9.5
  • release/v0.6.2
  • hotfix/v0.5.7
  • release/v0.5.6
  • release/v0.5.5
  • hotfix/v0.5.4
  • hotfix/v0.5.3
  • hotfix/v0.5.2
  • release/v0.5.1
  • hotfix/v0.5.0
  • hotfix/v0.4.9
  • hotfix/v0.4.8
  • hotfix/v0.4.7
  • release/v0.4.6
  • hotfix/v0.4.5
  • v1.3.55
  • v1.3.52
  • v1.3.50
  • v1.3.45
  • v1.3.42
  • v1.3.41
  • v1.3.40
  • v1.3.38
  • v1.3.37
  • v1.3.36
  • v1.3.35
  • v1.3.34
  • v1.3.33
  • v1.3.32
  • v1.3.31
  • v1.3.30
  • v1.3.29
  • v1.3.28
  • v1.3.27
  • v1.3.26
40 results

LineIdentifier.go

Blame
LineIdentifier.go 1.44 KiB
package coreinstruction

import (
	"gitlab.com/evatix-go/core/constants"
	"gitlab.com/evatix-go/core/reqtype"
)

type LineIdentifier struct {
	LineNumber   int             `json:"LineNumber,omitempty"`
	LineModifyAs reqtype.Request `json:"LineModifyAs,omitempty"`
}

func (it *LineIdentifier) IsInvalidLineNumber() bool {
	return it == nil || it.LineNumber < 0
}

func (it *LineIdentifier) IsInvalidLineNumberUsingLastLineNumber(lastLineNumber int) bool {
	return it == nil || it.LineNumber < 0 || it.LineNumber > lastLineNumber
}

func (it *LineIdentifier) HasLineNumber() bool {
	return it != nil && it.LineNumber > constants.InvalidValue
}

func (it *LineIdentifier) IsNewLineRequest() bool {
	return it.LineModifyAs.IsCreate()
}

func (it *LineIdentifier) IsDeleteLineRequest() bool {
	return it.HasLineNumber() &&
		it.LineModifyAs.IsDelete() ||
		it.LineModifyAs.IsDrop()
}

func (it *LineIdentifier) IsModifyLineRequest() bool {
	return it.HasLineNumber() &&
		it.LineModifyAs.IsUpdate()
}

func (it *LineIdentifier) IsAddNewOrModifyLineRequest() bool {
	return it.IsNewLineRequest() || it.IsModifyLineRequest()
}

func (it *LineIdentifier) ToBaseLineIdentifier() *BaseLineIdentifier {
	if it == nil {
		return nil
	}

	return NewBaseLineIdentifier(it.LineNumber, it.LineModifyAs)
}

func (it *LineIdentifier) Clone() *LineIdentifier {
	if it == nil {
		return nil
	}

	return &LineIdentifier{
		LineNumber:   it.LineNumber,
		LineModifyAs: it.LineModifyAs,
	}
}