defaultTypeFactory static method

NDEFRecord defaultTypeFactory(
  1. TypeNameFormat tnf,
  2. String classType
)

Construct an instance of a specific type (subclass) of NDEFRecord according to tnf and type

Implementation

static NDEFRecord defaultTypeFactory(TypeNameFormat tnf, String classType) {
  NDEFRecord record;
  if (tnf == TypeNameFormat.nfcWellKnown) {
    if (classType == UriRecord.classType) {
      record = UriRecord();
    } else if (classType == TextRecord.classType) {
      record = TextRecord();
    } else if (classType == SmartPosterRecord.classType) {
      record = SmartPosterRecord();
    } else if (classType == SignatureRecord.classType) {
      record = SignatureRecord();
    } else if (classType == HandoverRequestRecord.classType) {
      record = HandoverRequestRecord();
    } else if (classType == HandoverSelectRecord.classType) {
      record = HandoverSelectRecord();
    } else if (classType == HandoverMediationRecord.classType) {
      record = HandoverMediationRecord();
    } else if (classType == HandoverInitiateRecord.classType) {
      record = HandoverInitiateRecord();
    } else if (classType == HandoverCarrierRecord.classType) {
      record = HandoverCarrierRecord();
    } else if (classType == DeviceInformationRecord.classType) {
      record = DeviceInformationRecord();
    } else {
      record = WellKnownRecord();
    }
  } else if (tnf == TypeNameFormat.media) {
    if (classType == BluetoothEasyPairingRecord.classType) {
      record = BluetoothEasyPairingRecord();
    } else if (classType == BluetoothLowEnergyRecord.classType) {
      record = BluetoothLowEnergyRecord();
    } else {
      record = MimeRecord();
    }
  } else if (tnf == TypeNameFormat.absoluteURI) {
    record = AbsoluteUriRecord();
  } else {
    record = NDEFRecord(tnf: tnf);
  }
  return record;
}