Merge type comparison into a single function call
This commit is contained in:
29
file.go
29
file.go
@@ -368,24 +368,21 @@ func (obj *FileType) ApplyDir() bool {
|
||||
func (obj *FileType) Compare(typ Type) bool {
|
||||
switch typ.(type) {
|
||||
case *FileType:
|
||||
return obj.compare(typ.(*FileType))
|
||||
typ := typ.(*FileType)
|
||||
if obj.Name != typ.Name {
|
||||
return false
|
||||
}
|
||||
if obj.GetPath() != typ.Path {
|
||||
return false
|
||||
}
|
||||
if obj.Content != typ.Content {
|
||||
return false
|
||||
}
|
||||
if obj.State != typ.State {
|
||||
return false
|
||||
}
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func (obj *FileType) compare(typ *FileType) bool {
|
||||
if obj.Name != typ.Name {
|
||||
return false
|
||||
}
|
||||
if obj.GetPath() != typ.Path {
|
||||
return false
|
||||
}
|
||||
if obj.Content != typ.Content {
|
||||
return false
|
||||
}
|
||||
if obj.State != typ.State {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
23
service.go
23
service.go
@@ -304,21 +304,18 @@ func (obj *ServiceType) Apply() bool {
|
||||
func (obj *ServiceType) Compare(typ Type) bool {
|
||||
switch typ.(type) {
|
||||
case *ServiceType:
|
||||
return obj.compare(typ.(*ServiceType))
|
||||
typ := typ.(*ServiceType)
|
||||
if obj.Name != typ.Name {
|
||||
return false
|
||||
}
|
||||
if obj.State != typ.State {
|
||||
return false
|
||||
}
|
||||
if obj.Startup != typ.Startup {
|
||||
return false
|
||||
}
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func (obj *ServiceType) compare(typ *ServiceType) bool {
|
||||
if obj.Name != typ.Name {
|
||||
return false
|
||||
}
|
||||
if obj.State != typ.State {
|
||||
return false
|
||||
}
|
||||
if obj.Startup != typ.Startup {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
11
types.go
11
types.go
@@ -294,15 +294,12 @@ func (obj *NoopType) Compare(typ Type) bool {
|
||||
switch typ.(type) {
|
||||
// we can only compare NoopType to others of the same type
|
||||
case *NoopType:
|
||||
return obj.compare(typ.(*NoopType))
|
||||
typ := typ.(*NoopType)
|
||||
if obj.Name != typ.Name {
|
||||
return false
|
||||
}
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func (obj *NoopType) compare(typ *NoopType) bool {
|
||||
if obj.Name != typ.Name {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user