| 1 |
package sarif |
| 2 |
|
| 3 |
// Location ... |
| 4 |
type Location struct { |
| 5 |
Id *uint `json:"id,omitempty"` |
| 6 |
PhysicalLocation *PhysicalLocation `json:"physicalLocation,omitempty"` |
| 7 |
LogicalLocations []*LogicalLocation `json:"logicalLocations,omitempty"` |
| 8 |
Message *Message `json:"message,omitempty"` |
| 9 |
Annotations []*Region `json:"annotations,omitempty"` |
| 10 |
Relationships []*LocationRelationship `json:"relationships,omitempty"` |
| 11 |
PropertyBag |
| 12 |
} |
| 13 |
|
| 14 |
// NewLocation creates a new Location and returns a pointer to it |
| 15 |
func NewLocation() *Location { |
| 16 |
return &Location{} |
| 17 |
} |
| 18 |
|
| 19 |
// NewLocationWithPhysicalLocation creates a new LocationWithPhysicalLocation and returns a pointer to it |
| 20 |
func NewLocationWithPhysicalLocation(physicalLocation *PhysicalLocation) *Location { |
| 21 |
return NewLocation().WithPhysicalLocation(physicalLocation) |
| 22 |
} |
| 23 |
|
| 24 |
// WithId sets the Id |
| 25 |
func (location *Location) WithId(id int) *Location { |
| 26 |
i := uint(id) |
| 27 |
location.Id = &i |
| 28 |
return location |
| 29 |
} |
| 30 |
|
| 31 |
// WithPhysicalLocation sets the PhysicalLocation |
| 32 |
func (location *Location) WithPhysicalLocation(physicalLocation *PhysicalLocation) *Location { |
| 33 |
location.PhysicalLocation = physicalLocation |
| 34 |
return location |
| 35 |
} |
| 36 |
|
| 37 |
// WithLogicalLocations sets the LogicalLocations |
| 38 |
func (location *Location) WithLogicalLocations(logicalLocations []*LogicalLocation) *Location { |
| 39 |
location.LogicalLocations = logicalLocations |
| 40 |
return location |
| 41 |
} |
| 42 |
|
| 43 |
// AddLogicalLocations ... |
| 44 |
func (location *Location) AddLogicalLocations(logicalLocation *LogicalLocation) { |
| 45 |
location.LogicalLocations = append(location.LogicalLocations, logicalLocation) |
| 46 |
} |
| 47 |
|
| 48 |
// WithMessage sets the Message |
| 49 |
func (location *Location) WithMessage(message *Message) *Location { |
| 50 |
location.Message = message |
| 51 |
return location |
| 52 |
} |
| 53 |
|
| 54 |
// WithDescriptionText sets the DescriptionText |
| 55 |
func (location *Location) WithDescriptionText(text string) *Location { |
| 56 |
if location.Message == nil { |
| 57 |
location.Message = &Message{} |
| 58 |
} |
| 59 |
location.Message.Text = &text |
| 60 |
return location |
| 61 |
} |
| 62 |
|
| 63 |
// WithDescriptionMarkdown sets the DescriptionMarkdown |
| 64 |
func (location *Location) WithDescriptionMarkdown(markdown string) *Location { |
| 65 |
if location.Message == nil { |
| 66 |
location.Message = &Message{} |
| 67 |
} |
| 68 |
location.Message.Markdown = &markdown |
| 69 |
return location |
| 70 |
} |
| 71 |
|
| 72 |
// WithAnnotations sets the Annotations |
| 73 |
func (location *Location) WithAnnotations(annotations []*Region) *Location { |
| 74 |
location.Annotations = annotations |
| 75 |
return location |
| 76 |
} |
| 77 |
|
| 78 |
// AddAnnotation ... |
| 79 |
func (location *Location) AddAnnotation(annotation *Region) { |
| 80 |
location.Annotations = append(location.Annotations, annotation) |
| 81 |
} |
| 82 |
|
| 83 |
// WithRelationships sets the Relationships |
| 84 |
func (location *Location) WithRelationships(locationRelationships []*LocationRelationship) *Location { |
| 85 |
location.Relationships = locationRelationships |
| 86 |
return location |
| 87 |
} |
| 88 |
|
| 89 |
// AddRelationship ... |
| 90 |
func (location *Location) AddRelationship(locationRelationship *LocationRelationship) { |
| 91 |
location.Relationships = append(location.Relationships, locationRelationship) |
| 92 |
} |