All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.micronaut.core.bind.ExecutableBinder Maven / Gradle / Ivy

There is a newer version: 4.7.12
Show newest version
/*
 * Copyright 2017-2020 original authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.micronaut.core.bind;

import io.micronaut.core.bind.exceptions.UnsatisfiedArgumentException;
import io.micronaut.core.type.Executable;

/**
 * 

An ExecutableBinder is capable of taking a target {@link Executable} and fulfilling the argument * requirements using the provided binding source and {@link ArgumentBinderRegistry}

* *

The returned {@link BoundExecutable} will have all of the required arguments bound and * can then be called simply by calling invoke.

* *

If an argument could not be bound then an exception will be

* * @param The source type */ public interface ExecutableBinder { /** * Binds a given {@link Executable} using the given registry and source object. * * @param target The target executable * @param registry The registry to use * @param source The binding source * @param The executable target type * @param The executable return type * @return The bound executable * @throws UnsatisfiedArgumentException When the executable could not be satisfied */ BoundExecutable bind( Executable target, ArgumentBinderRegistry registry, S source ) throws UnsatisfiedArgumentException; /** * Binds a given {@link Executable} using the given registry and source object. Unlike {@link #bind(Executable, ArgumentBinderRegistry, Object)} this * method will not throw an {@link UnsatisfiedArgumentException} if an argument cannot be bound. Instead, the {@link BoundExecutable#getUnboundArguments()} property * will be populated with any arguments that could not be bound * * @param target The target executable * @param registry The registry to use * @param source The binding source * @param The executable target type * @param The executable return type * @return The bound executable */ BoundExecutable tryBind( Executable target, ArgumentBinderRegistry registry, S source ); }