/*
Pulp 3 API

Fetch, Upload, Organize, and Distribute Software Packages

API version: v3
Contact: pulp-list@redhat.com
*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

package pulpclient

import (
	"encoding/json"
	"fmt"
)

// PackageChecksumTypeEnum * `unknown` - unknown * `md5` - md5 * `sha1` - sha1 * `sha224` - sha224 * `sha256` - sha256 * `sha384` - sha384 * `sha512` - sha512
type PackageChecksumTypeEnum string

// List of PackageChecksumTypeEnum
const (
	PACKAGECHECKSUMTYPEENUM_UNKNOWN PackageChecksumTypeEnum = "unknown"
	PACKAGECHECKSUMTYPEENUM_MD5 PackageChecksumTypeEnum = "md5"
	PACKAGECHECKSUMTYPEENUM_SHA1 PackageChecksumTypeEnum = "sha1"
	PACKAGECHECKSUMTYPEENUM_SHA224 PackageChecksumTypeEnum = "sha224"
	PACKAGECHECKSUMTYPEENUM_SHA256 PackageChecksumTypeEnum = "sha256"
	PACKAGECHECKSUMTYPEENUM_SHA384 PackageChecksumTypeEnum = "sha384"
	PACKAGECHECKSUMTYPEENUM_SHA512 PackageChecksumTypeEnum = "sha512"
)

// All allowed values of PackageChecksumTypeEnum enum
var AllowedPackageChecksumTypeEnumEnumValues = []PackageChecksumTypeEnum{
	"unknown",
	"md5",
	"sha1",
	"sha224",
	"sha256",
	"sha384",
	"sha512",
}

func (v *PackageChecksumTypeEnum) UnmarshalJSON(src []byte) error {
	var value string
	err := json.Unmarshal(src, &value)
	if err != nil {
		return err
	}
	enumTypeValue := PackageChecksumTypeEnum(value)
	for _, existing := range AllowedPackageChecksumTypeEnumEnumValues {
		if existing == enumTypeValue {
			*v = enumTypeValue
			return nil
		}
	}

	return fmt.Errorf("%+v is not a valid PackageChecksumTypeEnum", value)
}

// NewPackageChecksumTypeEnumFromValue returns a pointer to a valid PackageChecksumTypeEnum
// for the value passed as argument, or an error if the value passed is not allowed by the enum
func NewPackageChecksumTypeEnumFromValue(v string) (*PackageChecksumTypeEnum, error) {
	ev := PackageChecksumTypeEnum(v)
	if ev.IsValid() {
		return &ev, nil
	} else {
		return nil, fmt.Errorf("invalid value '%v' for PackageChecksumTypeEnum: valid values are %v", v, AllowedPackageChecksumTypeEnumEnumValues)
	}
}

// IsValid return true if the value is valid for the enum, false otherwise
func (v PackageChecksumTypeEnum) IsValid() bool {
	for _, existing := range AllowedPackageChecksumTypeEnumEnumValues {
		if existing == v {
			return true
		}
	}
	return false
}

// Ptr returns reference to PackageChecksumTypeEnum value
func (v PackageChecksumTypeEnum) Ptr() *PackageChecksumTypeEnum {
	return &v
}

type NullablePackageChecksumTypeEnum struct {
	value *PackageChecksumTypeEnum
	isSet bool
}

func (v NullablePackageChecksumTypeEnum) Get() *PackageChecksumTypeEnum {
	return v.value
}

func (v *NullablePackageChecksumTypeEnum) Set(val *PackageChecksumTypeEnum) {
	v.value = val
	v.isSet = true
}

func (v NullablePackageChecksumTypeEnum) IsSet() bool {
	return v.isSet
}

func (v *NullablePackageChecksumTypeEnum) Unset() {
	v.value = nil
	v.isSet = false
}

func NewNullablePackageChecksumTypeEnum(val *PackageChecksumTypeEnum) *NullablePackageChecksumTypeEnum {
	return &NullablePackageChecksumTypeEnum{value: val, isSet: true}
}

func (v NullablePackageChecksumTypeEnum) MarshalJSON() ([]byte, error) {
	return json.Marshal(v.value)
}

func (v *NullablePackageChecksumTypeEnum) UnmarshalJSON(src []byte) error {
	v.isSet = true
	return json.Unmarshal(src, &v.value)
}

