blob: 984dff89e9d27f1d8369360775e0a5a3beec5da5 [file] [log] [blame]
Don Newton379ae252019-04-01 12:17:06 -04001// Copyright (C) MongoDB, Inc. 2017-present.
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may
4// not use this file except in compliance with the License. You may obtain
5// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
7package description
8
9import "fmt"
10
11// VersionRange represents a range of versions.
12type VersionRange struct {
13 Min int32
14 Max int32
15}
16
17// NewVersionRange creates a new VersionRange given a min and a max.
18func NewVersionRange(min, max int32) VersionRange {
19 return VersionRange{Min: min, Max: max}
20}
21
22// Includes returns a bool indicating whether the supplied integer is included
23// in the range.
24func (vr VersionRange) Includes(v int32) bool {
25 return v >= vr.Min && v <= vr.Max
26}
27
28// String implements the fmt.Stringer interface.
29func (vr VersionRange) String() string {
30 return fmt.Sprintf("[%d, %d]", vr.Min, vr.Max)
31}