// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

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

import (
	
	
	
	

	attribute 
)

//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    any
}

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: 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: 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: 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 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 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 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 any.
func ( Value) () any {
	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:
		,  := json.Marshal(.asInt64Slice())
		if  != nil {
			return fmt.Sprintf("invalid: %v", .asInt64Slice())
		}
		return string()
	case INT64:
		return strconv.FormatInt(.AsInt64(), 10)
	case FLOAT64SLICE:
		,  := json.Marshal(.asFloat64Slice())
		if  != nil {
			return fmt.Sprintf("invalid: %v", .asFloat64Slice())
		}
		return string()
	case FLOAT64:
		return fmt.Sprint(.AsFloat64())
	case STRINGSLICE:
		,  := json.Marshal(.asStringSlice())
		if  != nil {
			return fmt.Sprintf("invalid: %v", .asStringSlice())
		}
		return string()
	case STRING:
		return .stringly
	default:
		return "unknown"
	}
}

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