// automatically generated by the FlatBuffers compiler, do not modify
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names

library flatbuffers.goldens;

import 'dart:typed_data' show Uint8List;
import 'package:flat_buffers/flat_buffers.dart' as fb;


class Galaxy {
  Galaxy._(this._bc, this._bcOffset);
  factory Galaxy(List<int> bytes) {
    final rootRef = fb.BufferContext.fromBytes(bytes);
    return reader.read(rootRef, 0);
  }

  static const fb.Reader<Galaxy> reader = _GalaxyReader();

  final fb.BufferContext _bc;
  final int _bcOffset;

  int get numStars => const fb.Int64Reader().vTableGet(_bc, _bcOffset, 4, 0);

  @override
  String toString() {
    return 'Galaxy{numStars: ${numStars}}';
  }
}

class _GalaxyReader extends fb.TableReader<Galaxy> {
  const _GalaxyReader();

  @override
  Galaxy createObject(fb.BufferContext bc, int offset) => 
    Galaxy._(bc, offset);
}

class GalaxyBuilder {
  GalaxyBuilder(this.fbBuilder);

  final fb.Builder fbBuilder;

  void begin() {
    fbBuilder.startTable(1);
  }

  int addNumStars(int? numStars) {
    fbBuilder.addInt64(0, numStars);
    return fbBuilder.offset;
  }

  int finish() {
    return fbBuilder.endTable();
  }
}

class GalaxyObjectBuilder extends fb.ObjectBuilder {
  final int? _numStars;

  GalaxyObjectBuilder({
    int? numStars,
  })
      : _numStars = numStars;

  /// Finish building, and store into the [fbBuilder].
  @override
  int finish(fb.Builder fbBuilder) {
    fbBuilder.startTable(1);
    fbBuilder.addInt64(0, _numStars);
    return fbBuilder.endTable();
  }

  /// Convenience method to serialize to byte list.
  @override
  Uint8List toBytes([String? fileIdentifier]) {
    final fbBuilder = fb.Builder(deduplicateTables: false);
    fbBuilder.finish(finish(fbBuilder), fileIdentifier);
    return fbBuilder.buffer;
  }
}
class Universe {
  Universe._(this._bc, this._bcOffset);
  factory Universe(List<int> bytes) {
    final rootRef = fb.BufferContext.fromBytes(bytes);
    return reader.read(rootRef, 0);
  }

  static const fb.Reader<Universe> reader = _UniverseReader();

  final fb.BufferContext _bc;
  final int _bcOffset;

  double get age => const fb.Float64Reader().vTableGet(_bc, _bcOffset, 4, 0.0);
  List<Galaxy>? get galaxies => const fb.ListReader<Galaxy>(Galaxy.reader).vTableGetNullable(_bc, _bcOffset, 6);

  @override
  String toString() {
    return 'Universe{age: ${age}, galaxies: ${galaxies}}';
  }
}

class _UniverseReader extends fb.TableReader<Universe> {
  const _UniverseReader();

  @override
  Universe createObject(fb.BufferContext bc, int offset) => 
    Universe._(bc, offset);
}

class UniverseBuilder {
  UniverseBuilder(this.fbBuilder);

  final fb.Builder fbBuilder;

  void begin() {
    fbBuilder.startTable(2);
  }

  int addAge(double? age) {
    fbBuilder.addFloat64(0, age);
    return fbBuilder.offset;
  }
  int addGalaxiesOffset(int? offset) {
    fbBuilder.addOffset(1, offset);
    return fbBuilder.offset;
  }

  int finish() {
    return fbBuilder.endTable();
  }
}

class UniverseObjectBuilder extends fb.ObjectBuilder {
  final double? _age;
  final List<GalaxyObjectBuilder>? _galaxies;

  UniverseObjectBuilder({
    double? age,
    List<GalaxyObjectBuilder>? galaxies,
  })
      : _age = age,
        _galaxies = galaxies;

  /// Finish building, and store into the [fbBuilder].
  @override
  int finish(fb.Builder fbBuilder) {
    final int? galaxiesOffset = _galaxies == null ? null
        : fbBuilder.writeList(_galaxies!.map((b) => b.getOrCreateOffset(fbBuilder)).toList());
    fbBuilder.startTable(2);
    fbBuilder.addFloat64(0, _age);
    fbBuilder.addOffset(1, galaxiesOffset);
    return fbBuilder.endTable();
  }

  /// Convenience method to serialize to byte list.
  @override
  Uint8List toBytes([String? fileIdentifier]) {
    final fbBuilder = fb.Builder(deduplicateTables: false);
    fbBuilder.finish(finish(fbBuilder), fileIdentifier);
    return fbBuilder.buffer;
  }
}
