-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtype.go
46 lines (36 loc) · 1.35 KB
/
type.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 cwaqr
import "github.com/lukasmalkmus/cwa-qr/internal/pb"
//go:generate bin/stringer -type=EventType -linecomment -output=type_string.go
// EventType describes the type of an event. Types belong to one of two
// categories: permanent or temporary.
type EventType uint8
// IsPermanent return true if the event type describes a permanent event.
func (et EventType) IsPermanent() bool {
return et == OtherPermanent || (et >= Retail && et <= PublicBuilding)
}
// IsTemporary return true if the event type describes a temporary event.
func (et EventType) IsTemporary() bool {
return et == OtherTemporary || (et >= CulturalEvent && et <= WorshipService)
}
func (et EventType) toProto() pb.TraceLocationType {
if et.IsPermanent() || et.IsTemporary() {
return pb.TraceLocationType(et)
}
return pb.TraceLocationType_LOCATION_TYPE_UNSPECIFIED
}
// All available event types.
const (
Unknown EventType = iota // Unknown
OtherPermanent // Other Permanent
OtherTemporary // Other Temporary
Retail // Retail
FoodService // FoodS ervice
Craft // Craft
Workplace // Workplace
EducationalInstitution // Educational Institution
PublicBuilding // Public Building
CulturalEvent // Cultural Event
ClubActivity // Club Activity
PrivateEvent // Private Event
WorshipService // Worship service
)