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

namespace Google\Cloud\Retail\V2\Product;

use UnexpectedValueException;

/**
 * Product availability. If this field is unspecified, the product is
 * assumed to be in stock.
 *
 * Protobuf type <code>google.cloud.retail.v2.Product.Availability</code>
 */
class Availability
{
    /**
     * Default product availability. Default to
     * [Availability.IN_STOCK][google.cloud.retail.v2.Product.Availability.IN_STOCK]
     * if unset.
     *
     * Generated from protobuf enum <code>AVAILABILITY_UNSPECIFIED = 0;</code>
     */
    const AVAILABILITY_UNSPECIFIED = 0;
    /**
     * Product in stock.
     *
     * Generated from protobuf enum <code>IN_STOCK = 1;</code>
     */
    const IN_STOCK = 1;
    /**
     * Product out of stock.
     *
     * Generated from protobuf enum <code>OUT_OF_STOCK = 2;</code>
     */
    const OUT_OF_STOCK = 2;
    /**
     * Product that is in pre-order state.
     *
     * Generated from protobuf enum <code>PREORDER = 3;</code>
     */
    const PREORDER = 3;
    /**
     * Product that is back-ordered (i.e. temporarily out of stock).
     *
     * Generated from protobuf enum <code>BACKORDER = 4;</code>
     */
    const BACKORDER = 4;

    private static $valueToName = [
        self::AVAILABILITY_UNSPECIFIED => 'AVAILABILITY_UNSPECIFIED',
        self::IN_STOCK => 'IN_STOCK',
        self::OUT_OF_STOCK => 'OUT_OF_STOCK',
        self::PREORDER => 'PREORDER',
        self::BACKORDER => 'BACKORDER',
    ];

    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)) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no value defined for name %s', __CLASS__, $name));
        }
        return constant($const);
    }
}

// Adding a class alias for backwards compatibility with the previous class name.
class_alias(Availability::class, \Google\Cloud\Retail\V2\Product_Availability::class);

