<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/cloud/compute/v1/compute.proto

namespace Google\Cloud\Compute\V1\Backend;

use UnexpectedValueException;

/**
 * This field indicates whether this backend should be fully utilized before sending traffic to backends with default preference. The possible values are: - PREFERRED: Backends with this preference level will be filled up to their capacity limits first, based on RTT. - DEFAULT: If preferred backends don't have enough capacity, backends in this layer would be used and traffic would be assigned based on the load balancing algorithm you use. This is the default 
 *
 * Protobuf type <code>google.cloud.compute.v1.Backend.Preference</code>
 */
class Preference
{
    /**
     * A value indicating that the enum field is not set.
     *
     * Generated from protobuf enum <code>UNDEFINED_PREFERENCE = 0;</code>
     */
    const UNDEFINED_PREFERENCE = 0;
    /**
     * No preference.
     *
     * Generated from protobuf enum <code>DEFAULT = 115302945;</code>
     */
    const PBDEFAULT = 115302945;
    /**
     * If preference is unspecified, we set it to the DEFAULT value
     *
     * Generated from protobuf enum <code>PREFERENCE_UNSPECIFIED = 496219571;</code>
     */
    const PREFERENCE_UNSPECIFIED = 496219571;
    /**
     * Traffic will be sent to this backend first.
     *
     * Generated from protobuf enum <code>PREFERRED = 418847841;</code>
     */
    const PREFERRED = 418847841;

    private static $valueToName = [
        self::UNDEFINED_PREFERENCE => 'UNDEFINED_PREFERENCE',
        self::PBDEFAULT => 'DEFAULT',
        self::PREFERENCE_UNSPECIFIED => 'PREFERENCE_UNSPECIFIED',
        self::PREFERRED => 'PREFERRED',
    ];

    public static function name($value)
    {
        if (!isset(self::$valueToName[$value])) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no name defined for value %s', __CLASS__, $value));
        }
        return self::$valueToName[$value];
    }


    public static function value($name)
    {
        $const = __CLASS__ . '::' . strtoupper($name);
        if (!defined($const)) {
            $pbconst =  __CLASS__. '::PB' . strtoupper($name);
            if (!defined($pbconst)) {
                throw new UnexpectedValueException(sprintf(
                        'Enum %s has no value defined for name %s', __CLASS__, $name));
            }
            return constant($pbconst);
        }
        return constant($const);
    }
}


