Refactor mapping rules.
This commit is contained in:
parent
b9d02e6482
commit
08fc828b46
6 changed files with 176 additions and 165 deletions
20
internal/mappingrules/mapping_rule_base.go
Normal file
20
internal/mappingrules/mapping_rule_base.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package mappingrules
|
||||
|
||||
import "slices"
|
||||
|
||||
type MappingRuleBase struct {
|
||||
Name string
|
||||
Output RuleTarget
|
||||
Modes []string
|
||||
}
|
||||
|
||||
func (rule *MappingRuleBase) OutputName() string {
|
||||
return rule.Output.GetDeviceName()
|
||||
}
|
||||
|
||||
func (rule *MappingRuleBase) modeCheck(mode *string) bool {
|
||||
if rule.Modes[0] == "*" {
|
||||
return true
|
||||
}
|
||||
return slices.Contains(rule.Modes, *mode)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue