forked from hashicorp/terraform-plugin-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpression_step_element_key_value_exact.go
51 lines (39 loc) · 1.56 KB
/
expression_step_element_key_value_exact.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
47
48
49
50
51
package path
import (
"fmt"
"github.com/hashicorp/terraform-plugin-framework/attr"
)
// Ensure ExpressionStepElementKeyValueExact satisfies the Step interface.
// var _ Step = ExpressionStepElementKeyValueExact(/* ... */)
// ExpressionStepElementKeyValueExact is an attribute path expression for an exact Value
// element within a set. Sets do not use integer-based indexing.
type ExpressionStepElementKeyValueExact struct {
// Value is an interface, so it cannot be type aliased with methods.
attr.Value
}
// Equal returns true if the given ExpressionStep is a
// ExpressionStepElementKeyValueExact and the Value element key is equivalent.
func (s ExpressionStepElementKeyValueExact) Equal(o ExpressionStep) bool {
other, ok := o.(ExpressionStepElementKeyValueExact)
if !ok {
return false
}
return s.Value.Equal(other.Value)
}
// Matches returns true if the given PathStep is fulfilled by the
// ExpressionStepElementKeyValueExact condition.
func (s ExpressionStepElementKeyValueExact) Matches(pathStep PathStep) bool {
pathStepElementKeyValue, ok := pathStep.(PathStepElementKeyValue)
if !ok {
return false
}
return s.Value.Equal(pathStepElementKeyValue.Value)
}
// String returns the human-readable representation of the element key
// expression. It is intended for logging and error messages and is not
// protected by compatibility guarantees.
func (s ExpressionStepElementKeyValueExact) String() string {
return fmt.Sprintf("[Value(%s)]", s.Value.String())
}
// unexported satisfies the Step interface.
func (s ExpressionStepElementKeyValueExact) unexported() {}