getObjectBoxModel function

ModelDefinition getObjectBoxModel()

Returns the ObjectBox model definition for this project for use with obx.Store.new.

Implementation

obx_int.ModelDefinition getObjectBoxModel() {
  final model = obx_int.ModelInfo(
    entities: _entities,
    lastEntityId: const obx_int.IdUid(8, 3545193943964287321),
    lastIndexId: const obx_int.IdUid(10, 2562607691785884488),
    lastRelationId: const obx_int.IdUid(0, 0),
    lastSequenceId: const obx_int.IdUid(0, 0),
    retiredEntityUids: const [
      6577851630444107071,
      7232160148979644101,
      1626380097505653220,
      8703077377677002917,
    ],
    retiredIndexUids: const [],
    retiredPropertyUids: const [
      8533558606535966526,
      186652500592327727,
      6958767133850847832,
      982025843340250439,
      8748202970090119035,
      4351056340122089503,
      3042129134787051626,
      7080108967250840770,
      6134540636395211292,
      6451367421366127939,
      739514348179545731,
      5496943555991882359,
      1952333526486807260,
      832527306289090802,
      7386851300878634084,
      3670895088153145212,
      4294110920790186262,
      4258450413116392673,
      271186945961150400,
      839070883767347324,
      1041576258085578066,
      1985969293010174212,
      3199629041363565880,
      4262583096715220227,
      6731350213666359245,
      9055439141483260486,
      5373247350553835114,
      5887547629459090152,
      9080051665455361474,
      8526723714891434267,
    ],
    retiredRelationUids: const [],
    modelVersion: 5,
    modelVersionParserMinimum: 5,
    version: 1,
  );

  final bindings = <Type, obx_int.EntityDefinition>{
    WalletEntity: obx_int.EntityDefinition<WalletEntity>(
      model: _entities[0],
      toOneRelations: (WalletEntity object) => [object.safe],
      toManyRelations: (WalletEntity object) => {},
      getId: (WalletEntity object) => object.id,
      setId: (WalletEntity object, int id) {
        object.id = id;
      },
      objectToFB: (WalletEntity object, fb.Builder fbb) {
        final addressOffset = fbb.writeString(object.address);
        final nameOffset = object.name == null
            ? null
            : fbb.writeString(object.name!);
        final imagePathOffset = object.imagePath == null
            ? null
            : fbb.writeString(object.imagePath!);
        fbb.startTable(12);
        fbb.addInt64(0, object.id);
        fbb.addOffset(1, addressOffset);
        fbb.addInt64(2, object.safe.targetId);
        fbb.addInt64(3, object.derivation);
        fbb.addOffset(4, nameOffset);
        fbb.addInt64(5, object.number);
        fbb.addFloat32(6, object.balance);
        fbb.addInt64(8, object.keyPairTypeIndex);
        fbb.addOffset(10, imagePathOffset);
        fbb.finish(fbb.endTable());
        return object.id;
      },
      objectFromFB: (obx.Store store, ByteData fbData) {
        final buffer = fb.BufferContext(fbData);
        final rootOffset = buffer.derefObject(0);
        final addressParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGet(buffer, rootOffset, 6, '');
        final derivationParam = const fb.Int64Reader().vTableGetNullable(
          buffer,
          rootOffset,
          10,
        );
        final nameParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGetNullable(buffer, rootOffset, 12);
        final numberParam = const fb.Int64Reader().vTableGet(
          buffer,
          rootOffset,
          14,
          0,
        );
        final keyPairTypeIndexParam = const fb.Int64Reader().vTableGet(
          buffer,
          rootOffset,
          20,
          0,
        );
        final balanceParam = const fb.Float32Reader().vTableGet(
          buffer,
          rootOffset,
          16,
          0,
        );
        final imagePathParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGetNullable(buffer, rootOffset, 24);
        final object = WalletEntity(
          address: addressParam,
          derivation: derivationParam,
          name: nameParam,
          number: numberParam,
          keyPairTypeIndex: keyPairTypeIndexParam,
          balance: balanceParam,
          imagePath: imagePathParam,
        )..id = const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0);
        object.safe.targetId = const fb.Int64Reader().vTableGet(
          buffer,
          rootOffset,
          8,
          0,
        );
        object.safe.attach(store);
        return object;
      },
    ),
    Config: obx_int.EntityDefinition<Config>(
      model: _entities[1],
      toOneRelations: (Config object) => [],
      toManyRelations: (Config object) => {},
      getId: (Config object) => object.id,
      setId: (Config object, int id) {
        object.id = id;
      },
      objectToFB: (Config object, fb.Builder fbb) {
        final keyOffset = fbb.writeString(object.key);
        final valueOffset = fbb.writeString(object.value);
        fbb.startTable(4);
        fbb.addInt64(0, object.id);
        fbb.addOffset(1, keyOffset);
        fbb.addOffset(2, valueOffset);
        fbb.finish(fbb.endTable());
        return object.id;
      },
      objectFromFB: (obx.Store store, ByteData fbData) {
        final buffer = fb.BufferContext(fbData);
        final rootOffset = buffer.derefObject(0);
        final idParam = const fb.Int64Reader().vTableGet(
          buffer,
          rootOffset,
          4,
          0,
        );
        final keyParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGet(buffer, rootOffset, 6, '');
        final valueParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGet(buffer, rootOffset, 8, '');
        final object = Config(id: idParam, key: keyParam, value: valueParam);

        return object;
      },
    ),
    SafeEntity: obx_int.EntityDefinition<SafeEntity>(
      model: _entities[2],
      toOneRelations: (SafeEntity object) => [],
      toManyRelations: (SafeEntity object) => {
        obx_int.RelInfo<WalletEntity>.toOneBacklink(
          3,
          object.id,
          (WalletEntity srcObject) => srcObject.safe,
        ): object.wallets,
      },
      getId: (SafeEntity object) => object.id,
      setId: (SafeEntity object, int id) {
        object.id = id;
      },
      objectToFB: (SafeEntity object, fb.Builder fbb) {
        final nameOffset = fbb.writeString(object.name);
        final defaultAddressOffset = object.defaultAddress == null
            ? null
            : fbb.writeString(object.defaultAddress!);
        final rootAddressOffset = object.rootAddress == null
            ? null
            : fbb.writeString(object.rootAddress!);
        final imagePathOffset = object.imagePath == null
            ? null
            : fbb.writeString(object.imagePath!);
        final ivOffset = fbb.writeListInt8(object.iv);
        final cipherTextOffset = fbb.writeString(object.cipherText);
        final mnemonicLanguageOffset = fbb.writeString(object.mnemonicLanguage);
        final fingerprintOffset = fbb.writeString(object.fingerprint);
        final legacySaltOffset = object.legacySalt == null
            ? null
            : fbb.writeString(object.legacySalt!);
        final legacyPasswordOffset = object.legacyPassword == null
            ? null
            : fbb.writeString(object.legacyPassword!);
        fbb.startTable(17);
        fbb.addInt64(0, object.id);
        fbb.addInt64(1, object.number);
        fbb.addOffset(2, nameOffset);
        fbb.addOffset(3, defaultAddressOffset);
        fbb.addOffset(4, rootAddressOffset);
        fbb.addOffset(5, imagePathOffset);
        fbb.addOffset(6, ivOffset);
        fbb.addOffset(7, cipherTextOffset);
        fbb.addInt64(8, object.createdAt.millisecondsSinceEpoch);
        fbb.addOffset(9, mnemonicLanguageOffset);
        fbb.addBool(10, object.biometricEnabled);
        fbb.addInt64(11, object.biometricEnabledAt?.millisecondsSinceEpoch);
        fbb.addOffset(12, fingerprintOffset);
        fbb.addInt64(13, object.safeTypeIndex);
        fbb.addOffset(14, legacySaltOffset);
        fbb.addOffset(15, legacyPasswordOffset);
        fbb.finish(fbb.endTable());
        return object.id;
      },
      objectFromFB: (obx.Store store, ByteData fbData) {
        final buffer = fb.BufferContext(fbData);
        final rootOffset = buffer.derefObject(0);
        final biometricEnabledAtValue = const fb.Int64Reader()
            .vTableGetNullable(buffer, rootOffset, 26);
        final numberParam = const fb.Int64Reader().vTableGet(
          buffer,
          rootOffset,
          6,
          0,
        );
        final nameParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGet(buffer, rootOffset, 8, '');
        final fingerprintParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGet(buffer, rootOffset, 28, '');
        final ivParam =
            const fb.Uint8ListReader(
                  lazy: false,
                ).vTableGet(buffer, rootOffset, 16, Uint8List(0))
                as Uint8List;
        final cipherTextParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGet(buffer, rootOffset, 18, '');
        final defaultAddressParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGetNullable(buffer, rootOffset, 10);
        final rootAddressParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGetNullable(buffer, rootOffset, 12);
        final imagePathParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGetNullable(buffer, rootOffset, 14);
        final mnemonicLanguageParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGet(buffer, rootOffset, 22, '');
        final biometricEnabledParam = const fb.BoolReader().vTableGet(
          buffer,
          rootOffset,
          24,
          false,
        );
        final biometricEnabledAtParam = biometricEnabledAtValue == null
            ? null
            : DateTime.fromMillisecondsSinceEpoch(biometricEnabledAtValue);
        final safeTypeIndexParam = const fb.Int64Reader().vTableGet(
          buffer,
          rootOffset,
          30,
          0,
        );
        final legacySaltParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGetNullable(buffer, rootOffset, 32);
        final legacyPasswordParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGetNullable(buffer, rootOffset, 34);
        final object =
            SafeEntity(
                number: numberParam,
                name: nameParam,
                fingerprint: fingerprintParam,
                iv: ivParam,
                cipherText: cipherTextParam,
                defaultAddress: defaultAddressParam,
                rootAddress: rootAddressParam,
                imagePath: imagePathParam,
                mnemonicLanguage: mnemonicLanguageParam,
                biometricEnabled: biometricEnabledParam,
                biometricEnabledAt: biometricEnabledAtParam,
                safeTypeIndex: safeTypeIndexParam,
                legacySalt: legacySaltParam,
                legacyPassword: legacyPasswordParam,
              )
              ..id = const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0)
              ..createdAt = DateTime.fromMillisecondsSinceEpoch(
                const fb.Int64Reader().vTableGet(buffer, rootOffset, 20, 0),
              );
        obx_int.InternalToManyAccess.setRelInfo<SafeEntity>(
          object.wallets,
          store,
          obx_int.RelInfo<WalletEntity>.toOneBacklink(
            3,
            object.id,
            (WalletEntity srcObject) => srcObject.safe,
          ),
        );
        return object;
      },
    ),
    BootstrapEndpoint: obx_int.EntityDefinition<BootstrapEndpoint>(
      model: _entities[3],
      toOneRelations: (BootstrapEndpoint object) => [],
      toManyRelations: (BootstrapEndpoint object) => {},
      getId: (BootstrapEndpoint object) => object.id,
      setId: (BootstrapEndpoint object, int id) {
        object.id = id;
      },
      objectToFB: (BootstrapEndpoint object, fb.Builder fbb) {
        final networkOffset = fbb.writeString(object.network);
        final endpointTypeOffset = fbb.writeString(object.endpointType);
        final endpointOffset = fbb.writeString(object.endpoint);
        final sourceOffset = fbb.writeString(object.source);
        fbb.startTable(11);
        fbb.addInt64(0, object.id);
        fbb.addOffset(1, networkOffset);
        fbb.addOffset(2, endpointTypeOffset);
        fbb.addOffset(3, endpointOffset);
        fbb.addInt64(4, object.lastTested);
        fbb.addInt64(5, object.successRate);
        fbb.addInt64(6, object.averageLatency);
        fbb.addBool(7, object.isWorking);
        fbb.addInt64(8, object.lastUpdated);
        fbb.addOffset(9, sourceOffset);
        fbb.finish(fbb.endTable());
        return object.id;
      },
      objectFromFB: (obx.Store store, ByteData fbData) {
        final buffer = fb.BufferContext(fbData);
        final rootOffset = buffer.derefObject(0);
        final idParam = const fb.Int64Reader().vTableGet(
          buffer,
          rootOffset,
          4,
          0,
        );
        final networkParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGet(buffer, rootOffset, 6, '');
        final endpointTypeParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGet(buffer, rootOffset, 8, '');
        final endpointParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGet(buffer, rootOffset, 10, '');
        final lastTestedParam = const fb.Int64Reader().vTableGet(
          buffer,
          rootOffset,
          12,
          0,
        );
        final successRateParam = const fb.Int64Reader().vTableGet(
          buffer,
          rootOffset,
          14,
          0,
        );
        final averageLatencyParam = const fb.Int64Reader().vTableGet(
          buffer,
          rootOffset,
          16,
          0,
        );
        final isWorkingParam = const fb.BoolReader().vTableGet(
          buffer,
          rootOffset,
          18,
          false,
        );
        final lastUpdatedParam = const fb.Int64Reader().vTableGet(
          buffer,
          rootOffset,
          20,
          0,
        );
        final sourceParam = const fb.StringReader(
          asciiOptimization: true,
        ).vTableGet(buffer, rootOffset, 22, '');
        final object = BootstrapEndpoint(
          id: idParam,
          network: networkParam,
          endpointType: endpointTypeParam,
          endpoint: endpointParam,
          lastTested: lastTestedParam,
          successRate: successRateParam,
          averageLatency: averageLatencyParam,
          isWorking: isWorkingParam,
          lastUpdated: lastUpdatedParam,
          source: sourceParam,
        );

        return object;
      },
    ),
  };

  return obx_int.ModelDefinition(model, bindings);
}