2020-07-26 17:09:05 +08:00
|
|
|
package mapping
|
|
|
|
|
|
|
|
type (
|
2021-02-20 23:18:22 +08:00
|
|
|
// A Valuer interface defines the way to get values from the underlying object with keys.
|
2020-07-26 17:09:05 +08:00
|
|
|
Valuer interface {
|
2021-02-20 23:18:22 +08:00
|
|
|
// Value gets the value associated with the given key.
|
2020-07-26 17:09:05 +08:00
|
|
|
Value(key string) (interface{}, bool)
|
|
|
|
}
|
|
|
|
|
2021-02-20 23:18:22 +08:00
|
|
|
// A MapValuer is a map that can use Value method to get values with given keys.
|
2020-07-26 17:09:05 +08:00
|
|
|
MapValuer map[string]interface{}
|
|
|
|
)
|
|
|
|
|
2021-02-20 23:18:22 +08:00
|
|
|
// Value gets the value associated with the given key from mv.
|
2020-07-26 17:09:05 +08:00
|
|
|
func (mv MapValuer) Value(key string) (interface{}, bool) {
|
|
|
|
v, ok := mv[key]
|
|
|
|
return v, ok
|
|
|
|
}
|