package datatypes

import (
	

	
	
	
)

// This datatype stores the uuid in the database as a string. To store the uuid
// in the database as a binary (byte) array, please refer to datatypes.BinUUID.
type UUID uuid.UUID

// NewUUIDv1 generates a UUID version 1, panics on generation failure.
func () UUID {
	return UUID(uuid.Must(uuid.NewUUID()))
}

// NewUUIDv4 generates a UUID version 4, panics on generation failure.
func () UUID {
	return UUID(uuid.Must(uuid.NewRandom()))
}

// GormDataType gorm common data type.
func (UUID) () string {
	return "string"
}

// GormDBDataType gorm db data type.
func (UUID) ( *gorm.DB,  *schema.Field) string {
	switch .Dialector.Name() {
	case "mysql":
		return "LONGTEXT"
	case "postgres":
		return "UUID"
	case "sqlserver":
		return "NVARCHAR(128)"
	case "sqlite":
		return "TEXT"
	default:
		return ""
	}
}

// Scan is the scanner function for this datatype.
func ( *UUID) ( interface{}) error {
	var  uuid.UUID
	if  := .Scan();  != nil {
		return 
	}
	* = UUID()
	return nil
}

// Value is the valuer function for this datatype.
func ( UUID) () (driver.Value, error) {
	return uuid.UUID().Value()
}

// String returns the string form of the UUID.
func ( UUID) () string {
	return uuid.UUID().String()
}

// Equals returns true if string form of UUID matches other, false otherwise.
func ( UUID) ( UUID) bool {
	return .String() == .String()
}

// Length returns the number of characters in string form of UUID.
func ( UUID) () int {
	return len(.String())
}

// IsNil returns true if the UUID is a nil UUID (all zeroes), false otherwise.
func ( UUID) () bool {
	return uuid.UUID() == uuid.Nil
}

// IsEmpty returns true if UUID is nil UUID or of zero length, false otherwise.
func ( UUID) () bool {
	return .IsNil() || .Length() == 0
}

// IsNilPtr returns true if caller UUID ptr is nil, false otherwise.
func ( *UUID) () bool {
	return  == nil
}

// IsEmptyPtr returns true if caller UUID ptr is nil or it's value is empty.
func ( *UUID) () bool {
	return .IsNilPtr() || .IsEmpty()
}