<?php

 
 
 
 
 
 

namespace Google\Protobuf;

use Google\Protobuf\Internal\GetPublicDescriptorTrait;
use Google\Protobuf\Internal\GPBType;

class FieldDescriptor
{
    use GetPublicDescriptorTrait;

     
    private $internal_desc;

    


    public function __construct($internal_desc)
    {
        $this->internal_desc = $internal_desc;
    }

    


    public function getName()
    {
        return $this->internal_desc->getName();
    }

    


    public function getNumber()
    {
        return $this->internal_desc->getNumber();
    }

    




    public function getLabel()
    {
        return $this->internal_desc->getLabel();
    }

    


    public function isRequired()
    {
        return $this->internal_desc->isRequired();
    }

    


    public function isRepeated()
    {
        return $this->internal_desc->isRepeated();
    }

    


    public function getType()
    {
        return $this->internal_desc->getType();
    }

    


    public function getContainingOneof()
    {
        return $this->getPublicDescriptor($this->internal_desc->getContainingOneof());
    }

    




    public function getRealContainingOneof()
    {
        return $this->getPublicDescriptor($this->internal_desc->getRealContainingOneof());
    }

    


    public function hasOptionalKeyword()
    {
        return $this->internal_desc->hasOptionalKeyword();
    }

    



    public function getMessageType()
    {
        if ($this->getType() == GPBType::MESSAGE) {
            return $this->getPublicDescriptor($this->internal_desc->getMessageType());
        } else {
            throw new \Exception("Cannot get message type for non-message field '" . $this->getName() . "'");
        }
    }

    



    public function getEnumType()
    {
        if ($this->getType() == GPBType::ENUM) {
            return $this->getPublicDescriptor($this->internal_desc->getEnumType());
        } else {
            throw new \Exception("Cannot get enum type for non-enum field '" . $this->getName() . "'");
        }
    }

    


    public function isMap()
    {
        return $this->internal_desc->isMap();
    }
}
