-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmutex.go
33 lines (27 loc) · 863 Bytes
/
mutex.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
// Copyright 2020 Joakim Kennedy. All rights reserved. Use of
// this source code is governed by the included BSD license.
package stix2
import "fmt"
// Mutex represents the properties of a mutual exclusion (mutex) object.
type Mutex struct {
STIXCyberObservableObject
// Name specifies the name of the mutex object.
Name string `json:"name"`
}
func (o *Mutex) MarshalJSON() ([]byte, error) {
return marshalToJSONHelper(o)
}
// NewMutex creates a new Mutex object.
func NewMutex(value string, opts ...STIXOption) (*Mutex, error) {
if value == "" {
return nil, ErrInvalidParameter
}
base := newSTIXCyberObservableObject(TypeMutex)
obj := &Mutex{
STIXCyberObservableObject: base,
Name: value,
}
err := applyOptions(obj, opts)
obj.ID = NewObservableIdentifier(fmt.Sprintf("[\"%s\"]", value), TypeMutex)
return obj, err
}