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

namespace Google\Cloud\Firestore\Admin\V1\Index;

use UnexpectedValueException;

/**
 * The density configuration for the index.
 *
 * Protobuf type <code>google.firestore.admin.v1.Index.Density</code>
 */
class Density
{
    /**
     * Unspecified. It will use database default setting. This value is input
     * only.
     *
     * Generated from protobuf enum <code>DENSITY_UNSPECIFIED = 0;</code>
     */
    const DENSITY_UNSPECIFIED = 0;
    /**
     * In order for an index entry to be added, the document must
     * contain all fields specified in the index.
     * This is the only allowed value for indexes having ApiScope `ANY_API` and
     * `DATASTORE_MODE_API`.
     *
     * Generated from protobuf enum <code>SPARSE_ALL = 1;</code>
     */
    const SPARSE_ALL = 1;
    /**
     * In order for an index entry to be added, the document must
     * contain at least one of the fields specified in the index.
     * Non-existent fields are treated as having a NULL value when generating
     * index entries.
     *
     * Generated from protobuf enum <code>SPARSE_ANY = 2;</code>
     */
    const SPARSE_ANY = 2;
    /**
     * An index entry will be added regardless of whether the
     * document contains any of the fields specified in the index.
     * Non-existent fields are treated as having a NULL value when generating
     * index entries.
     *
     * Generated from protobuf enum <code>DENSE = 3;</code>
     */
    const DENSE = 3;

    private static $valueToName = [
        self::DENSITY_UNSPECIFIED => 'DENSITY_UNSPECIFIED',
        self::SPARSE_ALL => 'SPARSE_ALL',
        self::SPARSE_ANY => 'SPARSE_ANY',
        self::DENSE => 'DENSE',
    ];

    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(Density::class, \Google\Cloud\Firestore\Admin\V1\Index_Density::class);

