/*
SpaceTraders API

SpaceTraders is an open-universe game and learning platform that offers a set of HTTP endpoints to control a fleet of ships and explore a multiplayer universe.  The API is documented using [OpenAPI](https://github.com/SpaceTradersAPI/api-docs). You can send your first request right here in your browser to check the status of the game server.  ```json http {   \"method\": \"GET\",   \"url\": \"https://api.spacetraders.io/v2\", } ```  Unlike a traditional game, SpaceTraders does not have a first-party client or app to play the game. Instead, you can use the API to build your own client, write a script to automate your ships, or try an app built by the community.  We have a [Discord channel](https://discord.com/invite/jh6zurdWk5) where you can share your projects, ask questions, and get help from other players.   

API version: 2.0.0
Contact: joel@spacetraders.io
*/

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

package stapi

import (
	"encoding/json"
	"fmt"
)

// ShipNavFlightMode The ship's set speed when traveling between waypoints or systems.
type ShipNavFlightMode string

// List of ShipNavFlightMode
const (
	SHIPNAVFLIGHTMODE_DRIFT ShipNavFlightMode = "DRIFT"
	SHIPNAVFLIGHTMODE_STEALTH ShipNavFlightMode = "STEALTH"
	SHIPNAVFLIGHTMODE_CRUISE ShipNavFlightMode = "CRUISE"
	SHIPNAVFLIGHTMODE_BURN ShipNavFlightMode = "BURN"
)

// All allowed values of ShipNavFlightMode enum
var AllowedShipNavFlightModeEnumValues = []ShipNavFlightMode{
	"DRIFT",
	"STEALTH",
	"CRUISE",
	"BURN",
}

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

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

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

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

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

type NullableShipNavFlightMode struct {
	value *ShipNavFlightMode
	isSet bool
}

func (v NullableShipNavFlightMode) Get() *ShipNavFlightMode {
	return v.value
}

func (v *NullableShipNavFlightMode) Set(val *ShipNavFlightMode) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableShipNavFlightMode(val *ShipNavFlightMode) *NullableShipNavFlightMode {
	return &NullableShipNavFlightMode{value: val, isSet: true}
}

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

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

