Merge type comparison into a single function call

This commit is contained in:
James Shubin
2016-01-08 04:13:42 -05:00
parent d769309cc0
commit 45ff3b6aa4
3 changed files with 27 additions and 36 deletions

11
file.go
View File

@@ -368,13 +368,7 @@ func (obj *FileType) ApplyDir() bool {
func (obj *FileType) Compare(typ Type) bool {
switch typ.(type) {
case *FileType:
return obj.compare(typ.(*FileType))
default:
return false
}
}
func (obj *FileType) compare(typ *FileType) bool {
typ := typ.(*FileType)
if obj.Name != typ.Name {
return false
}
@@ -387,5 +381,8 @@ func (obj *FileType) compare(typ *FileType) bool {
if obj.State != typ.State {
return false
}
default:
return false
}
return true
}

View File

@@ -304,13 +304,7 @@ func (obj *ServiceType) Apply() bool {
func (obj *ServiceType) Compare(typ Type) bool {
switch typ.(type) {
case *ServiceType:
return obj.compare(typ.(*ServiceType))
default:
return false
}
}
func (obj *ServiceType) compare(typ *ServiceType) bool {
typ := typ.(*ServiceType)
if obj.Name != typ.Name {
return false
}
@@ -320,5 +314,8 @@ func (obj *ServiceType) compare(typ *ServiceType) bool {
if obj.Startup != typ.Startup {
return false
}
default:
return false
}
return true
}

View File

@@ -294,14 +294,11 @@ 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))
default:
typ := typ.(*NoopType)
if obj.Name != typ.Name {
return false
}
}
func (obj *NoopType) compare(typ *NoopType) bool {
if obj.Name != typ.Name {
default:
return false
}
return true