# automatically generated by the FlatBuffers compiler, do not modify

# namespace: flatbuf

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

# Switch-style case expression
class SimpleCase(object):
    __slots__ = ['_tab']

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

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

    # The expression whose value will be matched
    # SimpleCase
    def Expression(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from vastdb.vast_flatbuf.org.apache.arrow.computeir.flatbuf.Expression import Expression
            obj = Expression()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Matches for `expression`
    # SimpleCase
    def Matches(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            x = self._tab.Vector(o)
            x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
            x = self._tab.Indirect(x)
            from vastdb.vast_flatbuf.org.apache.arrow.computeir.flatbuf.CaseFragment import CaseFragment
            obj = CaseFragment()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # SimpleCase
    def MatchesLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # SimpleCase
    def MatchesIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        return o == 0

    # The default value if no cases match
    # SimpleCase
    def Else_(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from vastdb.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(3)
def SimpleCaseStart(builder):
    """This method is deprecated. Please switch to Start."""
    return Start(builder)
def AddExpression(builder, expression): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(expression), 0)
def SimpleCaseAddExpression(builder, expression):
    """This method is deprecated. Please switch to AddExpression."""
    return AddExpression(builder, expression)
def AddMatches(builder, matches): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(matches), 0)
def SimpleCaseAddMatches(builder, matches):
    """This method is deprecated. Please switch to AddMatches."""
    return AddMatches(builder, matches)
def StartMatchesVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def SimpleCaseStartMatchesVector(builder, numElems):
    """This method is deprecated. Please switch to Start."""
    return StartMatchesVector(builder, numElems)
def AddElse_(builder, else_): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(else_), 0)
def SimpleCaseAddElse_(builder, else_):
    """This method is deprecated. Please switch to AddElse_."""
    return AddElse_(builder, else_)
def End(builder): return builder.EndObject()
def SimpleCaseEnd(builder):
    """This method is deprecated. Please switch to End."""
    return End(builder)