@@ -43,12 +43,12 @@ func (x {{ $fieldType }}) String() string {
4343type { { $fieldListType } } []{ { $fieldType } }
4444
4545// Len returns the number of values in the collection.
46- func (l { { $fieldListType } }) Len() int {
46+ func (l { { $fieldListType } }) Len() int {
4747 return len(l)
4848}
4949
5050// Contains returns true if the collection contains the value.
51- func (l { { $fieldListType } }) Contains(v { { $fieldType } }) bool {
51+ func (l { { $fieldListType } }) Contains(v { { $fieldType } }) bool {
5252 for _, x := range l {
5353 if x == v {
5454 return true
@@ -59,7 +59,7 @@ func (l {{ $fieldListType}}) Contains(v {{ $fieldType}}) bool {
5959}
6060
6161// Equals returns true if the two collections are equal.
62- func (l { { $fieldListType } }) Equals(other { { $fieldListType } }) bool {
62+ func (l { { $fieldListType } }) Equals(other { { $fieldListType } }) bool {
6363 if len(l) != len(other) {
6464 return false
6565 }
@@ -74,7 +74,7 @@ func (l {{ $fieldListType}}) Equals(other {{ $fieldListType}}) bool {
7474}
7575
7676// Similar returns true if the two collections contain the same values.
77- func (l { { $fieldListType } }) Similar(other { { $fieldListType } }) bool {
77+ func (l { { $fieldListType } }) Similar(other { { $fieldListType } }) bool {
7878 if len(l) != len(other) {
7979 return false
8080 }
@@ -89,14 +89,14 @@ func (l {{ $fieldListType}}) Similar(other {{ $fieldListType}}) bool {
8989}
9090
9191// Add adds the values to the collection.
92- func (l *{ { $fieldListType } }) Add(v ...{ { $fieldType } }) *{ { $fieldListType } } {
92+ func (l *{ { $fieldListType } }) Add(v ...{ { $fieldType } }) *{ { $fieldListType } } {
9393 *l = append(*l, v...)
9494
9595 return l
9696}
9797
9898// AddIfNotContains adds the values to the collection if they are not already present.
99- func (l *{ { $fieldListType } }) AddIfNotContains(v ...{ { $fieldType } }) *{ { $fieldListType } } {
99+ func (l *{ { $fieldListType } }) AddIfNotContains(v ...{ { $fieldType } }) *{ { $fieldListType } } {
100100 for _, x := range v {
101101 if ! l.Contains(x) {
102102 l.Add(x)
@@ -107,7 +107,7 @@ func (l *{{ $fieldListType}}) AddIfNotContains(v ...{{ $fieldType}}) *{{ $fieldL
107107}
108108
109109// Remove removes the values from the collection.
110- func (l *{ { $fieldListType } }) Remove(v ...{ { $fieldType } }) *{ { $fieldListType } } {
110+ func (l *{ { $fieldListType } }) Remove(v ...{ { $fieldType } }) *{ { $fieldListType } } {
111111 for _, x := range v {
112112 for i, y := range *l {
113113 if y == x {
@@ -122,14 +122,28 @@ func (l *{{ $fieldListType}}) Remove(v ...{{ $fieldType}}) *{{ $fieldListType}}
122122}
123123
124124// Clear clears the collection.
125- func (l *{ { $fieldListType } }) Clear() *{ { $fieldListType } } {
126- *l = []{{ $fieldType } }{ }
125+ func (l *{ { $fieldListType } }) Clear() *{ { $fieldListType } } {
126+ *l = []{{ $fieldType } }{ }
127127
128128 return l
129129}
130130
131+ // Clone returns a pointer to a copy of the collection.
132+ func (l *{ { $fieldListType } }) Clone() *{ { $fieldListType } } {
133+ if l == nil {
134+ return nil
135+ }
136+
137+ items := make([]{ { $fieldType } }, len(*l))
138+ copy(items, *l)
139+
140+ result := { { $fieldListType } }(items)
141+
142+ return &result
143+ }
144+
131145// Strings returns a slice with all the strings of the collection items.
132- func (l { { $fieldListType } }) Strings() []string {
146+ func (l { { $fieldListType } }) Strings() []string {
133147 strings := make([]string, 0, len(l))
134148 for _, x := range l {
135149 strings = append(strings, x.String())
@@ -167,7 +181,7 @@ func New{{ $fieldListType }}() {{ $fieldListType }} {
167181}
168182
169183// New{ { $fieldListType } }With returns a new { { $fieldListType } } with the given values of the ENUM.
170- func New{ { $fieldListType } }With(v ...{ { $fieldType } }) { { $fieldListType } } {
184+ func New{ { $fieldListType } }With(v ...{ { $fieldType } }) { { $fieldListType } } {
171185 result := {{ $fieldListType } }{ }
172186 if len(v) > 0 {
173187 result.Add(v...)
0 commit comments