// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package attribute // import "go.opentelemetry.io/otel/attribute"

import (
	
	
	
	

	
	
)

//go:generate stringer -type=Type

// Type describes the type of the data Value holds.
type Type int // nolint: revive  // redefines builtin Type.

// Value represents the value part in key-value pairs.
type Value struct {
	vtype    Type
	numeric  uint64
	stringly string
	slice    interface{}
}

const (
	// INVALID is used for a Value with no value set.
	INVALID Type = iota
	// BOOL is a boolean Type Value.
	BOOL
	// INT64 is a 64-bit signed integral Type Value.
	INT64
	// FLOAT64 is a 64-bit floating point Type Value.
	FLOAT64
	// STRING is a string Type Value.
	STRING
	// BOOLSLICE is a slice of booleans Type Value.
	BOOLSLICE
	// INT64SLICE is a slice of 64-bit signed integral numbers Type Value.
	INT64SLICE
	// FLOAT64SLICE is a slice of 64-bit floating point numbers Type Value.
	FLOAT64SLICE
	// STRINGSLICE is a slice of strings Type Value.
	STRINGSLICE
)

// BoolValue creates a BOOL Value.
func ( bool) Value {
	return Value{
		vtype:   BOOL,
		numeric: internal.BoolToRaw(),
	}
}

// BoolSliceValue creates a BOOLSLICE Value.
func ( []bool) Value {
	return Value{vtype: BOOLSLICE, slice: attribute.BoolSliceValue()}
}

// IntValue creates an INT64 Value.
func ( int) Value {
	return Int64Value(int64())
}

// IntSliceValue creates an INTSLICE Value.
func ( []int) Value {
	var  int64
	 := reflect.New(reflect.ArrayOf(len(), reflect.TypeOf()))
	for ,  := range  {
		.Elem().Index().SetInt(int64())
	}
	return Value{
		vtype: INT64SLICE,
		slice: .Elem().Interface(),
	}
}

// Int64Value creates an INT64 Value.
func ( int64) Value {
	return Value{
		vtype:   INT64,
		numeric: internal.Int64ToRaw(),
	}
}

// Int64SliceValue creates an INT64SLICE Value.
func ( []int64) Value {
	return Value{vtype: INT64SLICE, slice: attribute.Int64SliceValue()}
}

// Float64Value creates a FLOAT64 Value.
func ( float64) Value {
	return Value{
		vtype:   FLOAT64,
		numeric: internal.Float64ToRaw(),
	}
}

// Float64SliceValue creates a FLOAT64SLICE Value.
func ( []float64) Value {
	return Value{vtype: FLOAT64SLICE, slice: attribute.Float64SliceValue()}
}

// StringValue creates a STRING Value.
func ( string) Value {
	return Value{
		vtype:    STRING,
		stringly: ,
	}
}

// StringSliceValue creates a STRINGSLICE Value.
func ( []string) Value {
	return Value{vtype: STRINGSLICE, slice: attribute.StringSliceValue()}
}

// Type returns a type of the Value.
func ( Value) () Type {
	return .vtype
}

// AsBool returns the bool value. Make sure that the Value's type is
// BOOL.
func ( Value) () bool {
	return internal.RawToBool(.numeric)
}

// AsBoolSlice returns the []bool value. Make sure that the Value's type is
// BOOLSLICE.
func ( Value) () []bool {
	if .vtype != BOOLSLICE {
		return nil
	}
	return .asBoolSlice()
}

func ( Value) () []bool {
	return attribute.AsBoolSlice(.slice)
}

// AsInt64 returns the int64 value. Make sure that the Value's type is
// INT64.
func ( Value) () int64 {
	return internal.RawToInt64(.numeric)
}

// AsInt64Slice returns the []int64 value. Make sure that the Value's type is
// INT64SLICE.
func ( Value) () []int64 {
	if .vtype != INT64SLICE {
		return nil
	}
	return .asInt64Slice()
}

func ( Value) () []int64 {
	return attribute.AsInt64Slice(.slice)
}

// AsFloat64 returns the float64 value. Make sure that the Value's
// type is FLOAT64.
func ( Value) () float64 {
	return internal.RawToFloat64(.numeric)
}

// AsFloat64Slice returns the []float64 value. Make sure that the Value's type is
// FLOAT64SLICE.
func ( Value) () []float64 {
	if .vtype != FLOAT64SLICE {
		return nil
	}
	return .asFloat64Slice()
}

func ( Value) () []float64 {
	return attribute.AsFloat64Slice(.slice)
}

// AsString returns the string value. Make sure that the Value's type
// is STRING.
func ( Value) () string {
	return .stringly
}

// AsStringSlice returns the []string value. Make sure that the Value's type is
// STRINGSLICE.
func ( Value) () []string {
	if .vtype != STRINGSLICE {
		return nil
	}
	return .asStringSlice()
}

func ( Value) () []string {
	return attribute.AsStringSlice(.slice)
}

type unknownValueType struct{}

// AsInterface returns Value's data as interface{}.
func ( Value) () interface{} {
	switch .Type() {
	case BOOL:
		return .AsBool()
	case BOOLSLICE:
		return .asBoolSlice()
	case INT64:
		return .AsInt64()
	case INT64SLICE:
		return .asInt64Slice()
	case FLOAT64:
		return .AsFloat64()
	case FLOAT64SLICE:
		return .asFloat64Slice()
	case STRING:
		return .stringly
	case STRINGSLICE:
		return .asStringSlice()
	}
	return unknownValueType{}
}

// Emit returns a string representation of Value's data.
func ( Value) () string {
	switch .Type() {
	case BOOLSLICE:
		return fmt.Sprint(.asBoolSlice())
	case BOOL:
		return strconv.FormatBool(.AsBool())
	case INT64SLICE:
		return fmt.Sprint(.asInt64Slice())
	case INT64:
		return strconv.FormatInt(.AsInt64(), 10)
	case FLOAT64SLICE:
		return fmt.Sprint(.asFloat64Slice())
	case FLOAT64:
		return fmt.Sprint(.AsFloat64())
	case STRINGSLICE:
		return fmt.Sprint(.asStringSlice())
	case STRING:
		return .stringly
	default:
		return "unknown"
	}
}

// MarshalJSON returns the JSON encoding of the Value.
func ( Value) () ([]byte, error) {
	var  struct {
		  string
		 interface{}
	}
	. = .Type().String()
	. = .AsInterface()
	return json.Marshal()
}