Skip to content

Commit

Permalink
reuse setHierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
reuvenharrison committed Aug 30, 2024
1 parent 0b2cee7 commit 430d296
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions checker/generator/value_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ type ValueSet struct {
actions []string
}

// ValueSetA messages start with the noun
type ValueSetA ValueSet

func (v ValueSetA) setHierarchy(hierarchy []string, attributed []bool) IValueSet {
func (v ValueSet) setHierarchy(hierarchy []string, attributed []bool) ValueSet {
if len(hierarchy) == 0 {
return v
}
Expand All @@ -64,6 +61,13 @@ func (v ValueSetA) setHierarchy(hierarchy []string, attributed []bool) IValueSet
return v
}

// ValueSetA messages start with the noun
type ValueSetA ValueSet

func (v ValueSetA) setHierarchy(hierarchy []string, attributed []bool) IValueSet {
return ValueSetA(ValueSet(v).setHierarchy(hierarchy, attributed))
}

func (v ValueSetA) generate(out io.Writer) {
generateMessage := func(hierarchy []string, atttibuted []bool, noun, adjective, action string) string {
return standardizeSpaces(fmt.Sprintf("%s of %s was %s", addAttribute(noun, adjective, v.adjectiveType), getHierarchyMessage(hierarchy, atttibuted), getActionMessage(action)))
Expand All @@ -80,14 +84,7 @@ func (v ValueSetA) generate(out io.Writer) {
type ValueSetB ValueSet

func (v ValueSetB) setHierarchy(hierarchy []string, attributed []bool) IValueSet {
if len(hierarchy) == 0 {
return v
}

v.hierarchy = append(v.hierarchy, hierarchy...)
v.attributed = append(v.attributed, attributed...)

return v
return ValueSetB(ValueSet(v).setHierarchy(hierarchy, attributed))
}

func (v ValueSetB) generate(out io.Writer) {
Expand Down

0 comments on commit 430d296

Please sign in to comment.