/* * Copyright (C) 2014 The Android Open Source Project * * 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 * * http://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 android.hardware.camera2.dispatch; import java.lang.reflect.Method; import static com.android.internal.util.Preconditions.*; /** * A dispatcher that replaces one argument with another; replaces any argument at an index * with another argument. * *
For example, we can override an {@code void onSomething(int x)} calls to have {@code x} always * equal to 1. Or, if using this with a duck typing dispatcher, we could even overwrite {@code x} to * be something * that's not an {@code int}.
* * @paramFor example, if a method {@code onAction(T1 a, Integer b, T2 c)} is invoked, and we wanted * to replace all occurrences of {@code b} with {@code 0xDEADBEEF}, we would set * {@code argumentIndex = 1} and {@code replaceWith = 0xDEADBEEF}.
* *If a method dispatched has less arguments than {@code argumentIndex}, it is * passed through with the arguments unchanged.
* * @param target destination dispatch type, methods will be redirected to this dispatcher * @param argumentIndex the numeric index of the argument {@code >= 0} * @param replaceWith arguments matching {@code argumentIndex} will be replaced with this object */ public ArgumentReplacingDispatcher(Dispatchable