# fetch

@Incubating
abstract fun <M> fetch(modelType: Class<M>): FetchModelResult<Model, M>(source)

Fetches a snapshot of the model of the given type for the default project using resilient model fetching.

See fetch for more details about resilient fetching.

#### Return

The fetch result.

#### Since

9.3.0

#### Parameters

modelType

The model type.

<M>

The model type.

@Incubating
abstract fun <T : Model?, M> fetch(target: T, modelType: Class<M>): FetchModelResult<T, M>(source)

Fetches a snapshot of the model of the given type for the given element using resilient model fetching.

See fetch for more details about resilient fetching.

#### Return

The fetch result.

#### Since

9.3.0

#### Parameters

target

The target element, usually a project.

modelType

The model type.

<T>

The target type.

<M>

The model type.

@Incubating
abstract fun <M, P> fetch(modelType: Class<M>, @Nullable parameterType: @Nullable Class<P>, @Nullable parameterInitializer: @Nullable Action<in P>): FetchModelResult<Model, M>(source)

Fetches a snapshot of the model of the given type using the given parameter using resilient model fetching.

See fetch for more details about resilient fetching.

#### Return

The fetch result.

#### Since

9.3.0

#### Parameters

modelType

The model type.

<M>

The model type.

parameterType

The parameter type.

<P>

The parameter type.

parameterInitializer

Action to configure the parameter

@Incubating
abstract fun <T : Model?, M, P> fetch(@Nullable target: @Nullable T, modelType: Class<M>, @Nullable parameterType: @Nullable Class<P>, @Nullable parameterInitializer: @Nullable Action<in P>): FetchModelResult<T, M>(source)

Fetches a snapshot of the model of the given type for the given element using the given parameter with resilient model fetching.

Unlike getModel, this method uses resilient model fetching which means that if the model cannot be fetched due to an error, the method will not throw an exception. Instead, it returns a FetchModelResult that contains either the successfully fetched model or the failure information.

This is particularly useful when you want to fetch multiple models and continue processing even if some models fail to load, or when you need detailed information about why a model fetch failed.

#### Return

A FetchModelResult containing the target, the fetched model (if successful), and any failures that occurred. Check getFailures to determine if the fetch was successful.

#### Since

9.3.0

#### Parameters

target

The target element, usually a project. Pass `null` to target the default project.

modelType

The model type to fetch.

parameterType

The parameter type used to configure the model fetch. Pass `null` if no parameter is needed.

parameterInitializer

Action to configure the parameter. Pass `null` if no parameter initialization is needed.

<T>

The target type.

<M>

The model type.

<P>

The parameter type.