-
Notifications
You must be signed in to change notification settings - Fork 18
/
regkey.go
43 lines (33 loc) · 940 Bytes
/
regkey.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
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0
package registry
import (
"fmt"
)
type RegistrationKey struct {
ArtifactType string `json:"artifactType"`
MediaType string `json:"mediaType"`
}
// check type match for constraint type.
var _ Registry[string, RegistrationKey]
func (k RegistrationKey) IsValid() bool {
return k.ArtifactType != "" || k.MediaType != ""
}
func (k RegistrationKey) GetArtifactType() string {
return k.ArtifactType
}
func (k RegistrationKey) GetMediaType() string {
return k.MediaType
}
func (k RegistrationKey) SetArtifact(arttype, medtatype string) RegistrationKey {
k.ArtifactType = arttype
k.MediaType = medtatype
return k
}
func (k RegistrationKey) Key() RegistrationKey {
return k
}
func (k RegistrationKey) String() string {
return fmt.Sprintf("%s:%s", k.ArtifactType, k.MediaType)
}