'''A Stub Table.'''

# Copyright (c) 2025 Carnegie Mellon University
# This code is subject to the license terms contained in the LICENSE file.

from typing import Any, Dict, List, Union

from .impl.table import TableFactory, Table
from .impl.table_catalog import TableCatalog


class StubType():
    '''A stub type.'''
    def __init__(self, token: str = 'stub'):
        self._token = token

    @property
    def token(self):
        '''Return the token.'''
        return self._token


class StubTable(Table):
    '''A Table representing a pandas Stub.'''
    name = 'stub'
    _value: StubType

    def to_csv(self, *args, **kwargs) -> str:
        '''Output the table as a CSV string.'''
        return 'stub'

    def as_dict(self, *args, **kwargs) -> Dict[Union[str, int], Any]:
        '''Convert table to a dictionary.'''
        return {'stub': StubType()}

    def drop(self, columns: List[Union[int, str]]) -> Table:
        '''Return a copy of this table with selected columns dropped.'''
        return self

    @property
    def columns(self) -> List[Union[int, str]]:
        '''Return the column names of the table.'''
        return []

    @columns.setter
    def columns(self, value: List[Union[int, str]]):
        '''Set the column names of the table.'''
        _ = value

    @property
    def empty(self):
        '''Return True if the table is empty.'''
        return True


def register(catalog: TableCatalog):
    '''Register the StubTable with the catalog.'''
    catalog.register(StubTable)
    TableFactory.register_constructor(StubType, StubTable)
    TableFactory.register_exporter(from_type=StubType, to_type=StubType, exporter=StubTable.value)
