package vals

import (
	

	
)

// HasKeyer wraps the HasKey method.
type HasKeyer interface {
	// HasKey returns whether the receiver has the given argument as a valid
	// key.
	HasKey(interface{}) bool
}

// HasKey returns whether a container has a key. It is implemented for the Map
// type, StructMap types, and types satisfying the HasKeyer interface. It falls
// back to iterating keys using IterateKeys, and if that fails, it falls back to
// calling Len and checking if key is a valid numeric or slice index. Otherwise
// it returns false.
func (,  interface{}) bool {
	switch container := .(type) {
	case HasKeyer:
		return .HasKey()
	case Map:
		return hashmap.HasKey(, )
	case StructMap:
		return hasKeyStructMap(, )
	case PseudoStructMap:
		return hasKeyStructMap(.Fields(), )
	default:
		var  bool
		 := IterateKeys(, func( interface{}) bool {
			if  ==  {
				 = true
			}
			return !
		})
		if  == nil {
			return 
		}
		if  := Len();  >= 0 {
			// TODO(xiaq): Not all types that implement Lener have numerical
			// indices
			,  := ConvertListIndex(, )
			return  == nil
		}
		return false
	}
}

func ( StructMap,  interface{}) bool {
	,  := .(string)
	if ! ||  == "" {
		return false
	}
	for ,  := range getStructMapInfo(reflect.TypeOf()).fieldNames {
		if  ==  {
			return true
		}
	}
	return false
}