# toClass method

Class<T> toClass()

Converts this ClassType into a Class instance used by Jetleaf.

Logic:

1. If declaration is provided, returns `Class.declared(declaration, pd)`.
2. If name is provided, returns `Class.forName(name, pd, package)`.
3. Otherwise, returns a generic `Class<T>` with the given pd and package.

### Example:

    final classRef = ClassType(name: 'UserService');
    final userClass = classRef.toClass();

    final declaredClassRef = ClassType(declaration: someTypeDeclaration);
    final declaredClass = declaredClassRef.toClass();

## Implementation

    Class<T> toClass() {
      if (declaration != null) {
        return Class.declared(declaration!, pd ?? ProtectionDomain.current());
      }

      if (name != null) {
        return Class.forName(name!, pd ?? ProtectionDomain.current(), package);
      }

      return Class<T>(pd ?? ProtectionDomain.current(), package);
    }