// ValueType specifies the type of values produced by this source,
// e.g. "string" or "date".
546738
func (a *CompositeAggregationHistogramValuesSource) ValueType(valueType string) *CompositeAggregationHistogramValuesSource {
	a.valueType = valueType
	return a
}
788627
func (v StringValue) encode(w io.Writer) error {
	raw := rawValue{
		Type: v.valueType(),
	}

	return raw.encodeString(w, string(v))
}
703117
func (ctx *Context) Type(str string) {
	ctx.Res.Set(HeaderContentType, str)
}
345402
func (s *ConfigurationOptionDescription) SetValueType(v string) *ConfigurationOptionDescription {
	s.ValueType = &v
	return s
}
997983
func reflectValues(valueType string, value interface{}) (reflect.Value, error) {
	theType, ok := typesMap[valueType]
	if !ok {
		return reflect.Value{}, NewErrUnsupportedType(valueType)
	}

	// For NULL we return an empty slice
	if value == nil {
		return reflect.MakeSlice(theType, 0, 0), nil
	}

	var theValue reflect.Value

	// Booleans
	if theType.String() == "[]bool" {
		bools := reflect.ValueOf(value)

		theValue = reflect.MakeSlice(theType, bools.Len(), bools.Len())
		for i := 0; i < bools.Len(); i++ {
			boolValue, err := getBoolValue(strings.Split(theType.String(), "[]")[1], bools.Index(i).Interface())
			if err != nil {
				return reflect.Value{}, err
			}

			theValue.Index(i).SetBool(boolValue)
		}

		return theValue, nil
	}

	// Integers
	if strings.HasPrefix(theType.String(), "[]int") {
		ints := reflect.ValueOf(value)

		theValue = reflect.MakeSlice(theType, ints.Len(), ints.Len())
		for i := 0; i < ints.Len(); i++ {
			intValue, err := getIntValue(strings.Split(theType.String(), "[]")[1], ints.Index(i).Interface())
			if err != nil {
				return reflect.Value{}, err
			}

			theValue.Index(i).SetInt(intValue)
		}

		return theValue, nil
	}

	// Unsigned integers
	if strings.HasPrefix(theType.String(), "[]uint") {
		uints := reflect.ValueOf(value)

		theValue = reflect.MakeSlice(theType, uints.Len(), uints.Len())
		for i := 0; i < uints.Len(); i++ {
			uintValue, err := getUintValue(strings.Split(theType.String(), "[]")[1], uints.Index(i).Interface())
			if err != nil {
				return reflect.Value{}, err
			}

			theValue.Index(i).SetUint(uintValue)
		}

		return theValue, nil
	}

	// Floating point numbers
	if strings.HasPrefix(theType.String(), "[]float") {
		floats := reflect.ValueOf(value)

		theValue = reflect.MakeSlice(theType, floats.Len(), floats.Len())
		for i := 0; i < floats.Len(); i++ {
			floatValue, err := getFloatValue(strings.Split(theType.String(), "[]")[1], floats.Index(i).Interface())
			if err != nil {
				return reflect.Value{}, err
			}

			theValue.Index(i).SetFloat(floatValue)
		}

		return theValue, nil
	}

	// Strings
	if theType.String() == "[]string" {
		strs := reflect.ValueOf(value)

		theValue = reflect.MakeSlice(theType, strs.Len(), strs.Len())
		for i := 0; i < strs.Len(); i++ {
			strValue, err := getStringValue(strings.Split(theType.String(), "[]")[1], strs.Index(i).Interface())
			if err != nil {
				return reflect.Value{}, err
			}

			theValue.Index(i).SetString(strValue)
		}

		return theValue, nil
	}

	return reflect.Value{}, NewErrUnsupportedType(valueType)
}
736110
func (s *CountService) Type(typ ...string) *CountService {
	if s.typ == nil {
		s.typ = make([]string, 0)
	}
	s.typ = append(s.typ, typ...)
	return s
}
1204719
func ValueTypeFromNode(n Node) value.ValueType {
	switch nt := n.(type) {
	case *FuncNode:
		if nt == nil {
			return value.UnknownType
		}
		if nt.F.CustomFunc == nil {
			return value.UnknownType
		}
		return nt.F.Type()
	case *StringNode:
		return value.StringType
	case *IdentityNode:
		// Identity types will draw type from context.
		return value.UnknownType
	case *NumberNode:
		return value.NumberType
	case *BooleanNode:
		return value.BoolType
	case *BinaryNode:
		switch nt.Operator.T {
		case lex.TokenLogicAnd, lex.TokenAnd, lex.TokenLogicOr, lex.TokenOr,
			lex.TokenEqual, lex.TokenEqualEqual:
			return value.BoolType
		case lex.TokenMultiply, lex.TokenMinus, lex.TokenAdd, lex.TokenDivide:
			return value.NumberType
		case lex.TokenModulus:
			return value.IntType
		case lex.TokenLT, lex.TokenLE, lex.TokenGT, lex.TokenGE:
			return value.BoolType
		}
	}
	return value.UnknownType
}
551631
func (r *SearchRequest) SearchType(searchType string) *SearchRequest {
	r.searchType = searchType
	return r
}
1308873
func valueToString(v reflect.Value) (string, error) {
    if !v.IsValid() {
        return "null", nil
    }

    switch v.Kind() {
    case reflect.Ptr:
        return valueToString(reflect.Indirect(v))
    case reflect.Interface:
        return valueToString(v.Elem())
    case reflect.Bool:
        x := v.Bool()
        if x {
            return "true", nil
        } else {
            return "false", nil
        }

    case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
        return strconv.FormatInt(v.Int(), 10), nil
    case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
        return strconv.FormatUint(v.Uint(), 10), nil
    case reflect.UnsafePointer:
        return strconv.FormatUint(uint64(v.Pointer()), 10), nil

    case reflect.Float32, reflect.Float64:
        return strconv.FormatFloat(v.Float(), 'g', -1, 64), nil

    case reflect.String:
        return v.String(), nil

    //This is kind of a rough hack to replace the old []byte
    //detection with reflect.Uint8Type, it doesn't catch
    //zero-length byte slices
    case reflect.Slice:
        typ := v.Type()
        if typ.Elem().Kind() == reflect.Uint || typ.Elem().Kind() == reflect.Uint8 || typ.Elem().Kind() == reflect.Uint16 || typ.Elem().Kind() == reflect.Uint32 || typ.Elem().Kind() == reflect.Uint64 || typ.Elem().Kind() == reflect.Uintptr {
            if v.Len() > 0 {
                if v.Index(0).OverflowUint(257) {
                    return string(v.Interface().([]byte)), nil
                }
            }
        }
    }
    return "", errors.New("Unsupported type")
}
723280
func valueTypeOf(prefix string, att *design.AttributeDefinition) string {
	switch att.Type.Kind() {
	case design.BooleanKind:
		return prefix + "bool"
	case design.IntegerKind:
		return prefix + "int"
	case design.NumberKind:
		return prefix + "float"
	case design.StringKind:
		return prefix + "string"
	case design.ArrayKind:
		return valueTypeOf(prefix+"[]", arrayAttribute(att))
	case design.HashKind:
		key, elm := hashAttribute(att)
		return valueTypeOf(prefix+"map["+valueTypeOf("", key)+"]", elm)
	}
	return prefix + "interface{}"
}
929584
func FormatValue(value interface{}) string {
	// Based on code in k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/validation/field/errors.go
	valueType := reflect.TypeOf(value)
	if value == nil || valueType == nil {
		value = "null"
	} else if valueType.Kind() == reflect.Ptr {
		if reflectValue := reflect.ValueOf(value); reflectValue.IsNil() {
			value = "null"
		} else {
			value = reflectValue.Elem().Interface()
		}
	}
	switch t := value.(type) {
	case int64, int32, float64, float32, bool:
		// use simple printer for simple types
		return fmt.Sprintf("%v", value)
	case string:
		return fmt.Sprintf("%q", t)
	case fmt.Stringer:
		// anything that defines String() is better than raw struct
		return fmt.Sprintf("%s", t.String())
	default:
		// fallback to raw struct
		// TODO: internal types have panic guards against json.Marshaling to prevent
		// accidental use of internal types in external serialized form.  For now, use
		// %#v, although it would be better to show a more expressive output in the future
		return fmt.Sprintf("%#v", value)
	}
}
1074781
func (q *SearchSortField) Type(value string) *SearchSortField {
	q.options["type"] = value
	return q
}
356876
func GetValuesByType(row Row, types []FieldType) []interface{} {
	if len(row) != len(types) {
		panic(fmt.Sprintf("column and type's length are not the same! row:%d, types:%d", len(row), len(types)))
	}
	values := make([]interface{}, len(types))
	for i, t := range types {
		values[i] = GetValueByTypeAtIndex(row, t, i)
	}
	return values
}
306966
func (a TermsAggregation) ValueType(valueType string) TermsAggregation {
	a.valueType = valueType
	return a
}
362384
func (q *QueryStringQuery) Type(typ string) *QueryStringQuery {
	q.typ = typ
	return q
}
356852
func equalValueType(st1, st2 *ValueType) bool {
	return st1.Type == st2.Type && st1.Unit == st2.Unit
}
1042528
func (g *Generator) ConvertType(from, to string) {
	g.typeConversions[from] = to
}