createProperty method

  1. @override
AsserestFtpProperty createProperty(
  1. Uri url,
  2. Duration timeout,
  3. bool accessible,
  4. int? tryCount,
  5. UnmodifiableMapView<String, dynamic> additionalProperty,
)

Define the construction of AsserestProperty with given url, timeout, accessible and tryCount with additionalProperty for those non-standard properties found in Map.

Implementation

@override
AsserestFtpProperty createProperty(Uri url, Duration timeout, bool accessible,
    int? tryCount, UnmodifiableMapView<String, dynamic> additionalProperty) {
  final SecurityType security = SecurityType.values
      .singleWhere((e) => e.name == additionalProperty["security"]);

  final List<Map<String, dynamic>>? access = additionalProperty["access"];
  if (access != null && !accessible) {
    throw OperatingInDeniedFTPException._();
  }

  return AsserestFtpProperty._(
      url.replace(pathSegments: const []),
      accessible,
      timeout,
      tryCount,
      additionalProperty["username"] ?? "anonymous",
      additionalProperty["password"],
      security,
      access != null
          ? UniqueList.from(
              access.map(
                  (e) => AsserestFileAccess(e["target_path"], e["success"])),
              growable: false,
              nullable: false,
              strict: false)
          : null);
}