# automatically generated by the FlatBuffers compiler, do not modify

# namespace: flatbuf

import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()

# Conditional case statement expression
class ConditionalCase(object):
    __slots__ = ['_tab']

    @classmethod
    def GetRootAs(cls, buf, offset=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = ConditionalCase()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsConditionalCase(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    # ConditionalCase
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # List of conditions to evaluate
    # ConditionalCase
    def Conditions(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            x = self._tab.Vector(o)
            x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
            x = self._tab.Indirect(x)
            from vast_flatbuf.org.apache.arrow.computeir.flatbuf.CaseFragment import CaseFragment
            obj = CaseFragment()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # ConditionalCase
    def ConditionsLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # ConditionalCase
    def ConditionsIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        return o == 0

    # The default value if no cases match. This is typically NULL in SQL
    # implementations.
    #
    # Defaulting to NULL is a frontend choice, so producers must specify NULL
    # if that's their desired behavior.
    # ConditionalCase
    def Else_(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from vast_flatbuf.org.apache.arrow.computeir.flatbuf.Expression import Expression
            obj = Expression()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

def Start(builder): builder.StartObject(2)
def ConditionalCaseStart(builder):
    """This method is deprecated. Please switch to Start."""
    return Start(builder)
def AddConditions(builder, conditions): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(conditions), 0)
def ConditionalCaseAddConditions(builder, conditions):
    """This method is deprecated. Please switch to AddConditions."""
    return AddConditions(builder, conditions)
def StartConditionsVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def ConditionalCaseStartConditionsVector(builder, numElems):
    """This method is deprecated. Please switch to Start."""
    return StartConditionsVector(builder, numElems)
def AddElse_(builder, else_): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(else_), 0)
def ConditionalCaseAddElse_(builder, else_):
    """This method is deprecated. Please switch to AddElse_."""
    return AddElse_(builder, else_)
def End(builder): return builder.EndObject()
def ConditionalCaseEnd(builder):
    """This method is deprecated. Please switch to End."""
    return End(builder)