-
Notifications
You must be signed in to change notification settings - Fork 276
/
Copy pathartifact_sort_by.go
46 lines (43 loc) · 1.06 KB
/
artifact_sort_by.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package models
type ArtifactSortBy int
const (
GROUPID_ARTIFACTSORTBY ArtifactSortBy = iota
ARTIFACTID_ARTIFACTSORTBY
CREATEDON_ARTIFACTSORTBY
MODIFIEDON_ARTIFACTSORTBY
ARTIFACTTYPE_ARTIFACTSORTBY
NAME_ARTIFACTSORTBY
)
func (i ArtifactSortBy) String() string {
return []string{"groupId", "artifactId", "createdOn", "modifiedOn", "artifactType", "name"}[i]
}
func ParseArtifactSortBy(v string) (any, error) {
result := GROUPID_ARTIFACTSORTBY
switch v {
case "groupId":
result = GROUPID_ARTIFACTSORTBY
case "artifactId":
result = ARTIFACTID_ARTIFACTSORTBY
case "createdOn":
result = CREATEDON_ARTIFACTSORTBY
case "modifiedOn":
result = MODIFIEDON_ARTIFACTSORTBY
case "artifactType":
result = ARTIFACTTYPE_ARTIFACTSORTBY
case "name":
result = NAME_ARTIFACTSORTBY
default:
return nil, nil
}
return &result, nil
}
func SerializeArtifactSortBy(values []ArtifactSortBy) []string {
result := make([]string, len(values))
for i, v := range values {
result[i] = v.String()
}
return result
}
func (i ArtifactSortBy) isMultiValue() bool {
return false
}