feat(aa): rule interface: replace less & equal by the compare method.

- set a new alphabet order to sort AARE based string.
- unify compare function for all rules
- handle some special sort order, eg: base include
This commit is contained in:
Alexandre Pujol 2024-06-19 18:34:58 +01:00
parent 747292e954
commit 4cbacc186c
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
22 changed files with 250 additions and 399 deletions

View file

@ -28,25 +28,18 @@ func (r *PivotRoot) Validate() error {
return nil
}
func (r *PivotRoot) Less(other any) bool {
func (r *PivotRoot) Compare(other Rule) int {
o, _ := other.(*PivotRoot)
if r.OldRoot != o.OldRoot {
return r.OldRoot < o.OldRoot
if res := compare(r.OldRoot, o.OldRoot); res != 0 {
return res
}
if r.NewRoot != o.NewRoot {
return r.NewRoot < o.NewRoot
if res := compare(r.NewRoot, o.NewRoot); res != 0 {
return res
}
if r.TargetProfile != o.TargetProfile {
return r.TargetProfile < o.TargetProfile
if res := compare(r.TargetProfile, o.TargetProfile); res != 0 {
return res
}
return r.Qualifier.Less(o.Qualifier)
}
func (r *PivotRoot) Equals(other any) bool {
o, _ := other.(*PivotRoot)
return r.OldRoot == o.OldRoot && r.NewRoot == o.NewRoot &&
r.TargetProfile == o.TargetProfile &&
r.Qualifier.Equals(o.Qualifier)
return r.Qualifier.Compare(o.Qualifier)
}
func (r *PivotRoot) String() string {