# getClass method

Class getClass([

1. ProtectionDomain? domain,
2. String? package

])

Gets the Class metadata for this object's runtime type.

Parameters:

- `domain`: Optional protection domain
- `package`: Optional package name to search with

Returns:

- A Class<Object> instance representing the object's type
- Uses the current protection domain for security

Equivalent to:

    Class.forType<Object>(runtimeType, ProtectionDomain.current())

## Implementation

    Class getClass([ProtectionDomain? domain, String? package]) {
      final Object self = this;

      if (self is Iterable<Object?>) {
        Class<Object?> Function<E>() f = switch (self) {
          List<Object?>() => <E>() => Class<List<E>>(null, null),
          Set<Object?>() => <E>() => Class<Set<E>>(null, null),
          _ => <E>() => Class<Iterable<E>>(null, null),
        };
        return extractIterableTypeArgument(self, f) as Class<Object?>;
      }

      if (self is Iterable) {
        Class Function<E>() f = switch (self) {
          List() => <E>() => Class<List<E>>(null, null),
          Set() => <E>() => Class<Set<E>>(null, null),
          _ => <E>() => Class<Iterable<E>>(null, null),
        };
        return extractIterableTypeArgument(self, f) as Class<Object?>;
      }

      if (self is Map<Object?, Object?>) {
        Class<Object?> Function<E, F>() f = switch (self) {
          Map<Object?, Object?>() => <E, F>() => Class<Map<E, F>>(null, null),
        };
        return extractMapTypeArguments(self, f) as Class<Object?>;
      }

      if (self is Map) {
        Class Function<E, F>() f = switch (self) {
          Map() => <E, F>() => Class<Map<E, F>>(null, null),
        };
        return extractMapTypeArguments(self, f) as Class<Object?>;
      }

      try {
        return Class.fromQualifiedName(ReflectionUtils.findQualifiedName(self), domain ?? ProtectionDomain.system());
      } on ClassNotFoundException catch (_) {
        return Class.forObject(self, domain ?? ProtectionDomain.system(), package);
      }
    }