enum ResourceStatus { initial, loading, success, error, empty }

class Resource<T> {
  final ResourceStatus status;
  final T? data;
  final String? message;

  const Resource._({required this.status, this.data, this.message});

  const Resource.initial() : this._(status: ResourceStatus.initial);

  const Resource.loading() : this._(status: ResourceStatus.loading);

  const Resource.success(T data) : this._(status: ResourceStatus.success, data: data);

  const Resource.error(String message) : this._(status: ResourceStatus.error, message: message);

  const Resource.empty() : this._(status: ResourceStatus.empty);

  bool get isInitial => status == ResourceStatus.initial;

  bool get isLoading => status == ResourceStatus.loading;

  bool get isSuccess => status == ResourceStatus.success;

  bool get isError => status == ResourceStatus.error;

  bool get isEmpty => status == ResourceStatus.empty;

  @override
  String toString() {
    return 'Resource{status: $status, data: $data, message: $message}';
  }
}
