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

namespace Google\Cloud\Dataproc\V1\WorkflowNode;

use UnexpectedValueException;

/**
 * The workflow node state.
 *
 * Protobuf type <code>google.cloud.dataproc.v1.WorkflowNode.NodeState</code>
 */
class NodeState
{
    /**
     * State is unspecified.
     *
     * Generated from protobuf enum <code>NODE_STATE_UNSPECIFIED = 0;</code>
     */
    const NODE_STATE_UNSPECIFIED = 0;
    /**
     * The node is awaiting prerequisite node to finish.
     *
     * Generated from protobuf enum <code>BLOCKED = 1;</code>
     */
    const BLOCKED = 1;
    /**
     * The node is runnable but not running.
     *
     * Generated from protobuf enum <code>RUNNABLE = 2;</code>
     */
    const RUNNABLE = 2;
    /**
     * The node is running.
     *
     * Generated from protobuf enum <code>RUNNING = 3;</code>
     */
    const RUNNING = 3;
    /**
     * The node completed successfully.
     *
     * Generated from protobuf enum <code>COMPLETED = 4;</code>
     */
    const COMPLETED = 4;
    /**
     * The node failed. A node can be marked FAILED because
     * its ancestor or peer failed.
     *
     * Generated from protobuf enum <code>FAILED = 5;</code>
     */
    const FAILED = 5;

    private static $valueToName = [
        self::NODE_STATE_UNSPECIFIED => 'NODE_STATE_UNSPECIFIED',
        self::BLOCKED => 'BLOCKED',
        self::RUNNABLE => 'RUNNABLE',
        self::RUNNING => 'RUNNING',
        self::COMPLETED => 'COMPLETED',
        self::FAILED => 'FAILED',
    ];

    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(NodeState::class, \Google\Cloud\Dataproc\V1\WorkflowNode_NodeState::class);

