org.basinmc.plunger.mapping.ParameterNameMapping Maven / Gradle / Ivy
/*
* Copyright 2018 Johannes Donath
* and other copyright owners as documented in the project's IP log.
*
* 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 org.basinmc.plunger.mapping;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import java.util.Optional;
/**
* @author Johannes Donath
*/
public interface ParameterNameMapping {
/**
* Retrieves the target name for a specified method parameter.
*
* The class name and method signature will be passed in the JVM format (e.g. slashes ("/")
* will be used instead of dots to separate package elements. For instance,
* "org.basinmc.plunger.Class" will become "org/basinmc/plunger/Class").
*
* In case of method signatures, the return type and parameters will be specified within the
* signature (for instance, a method of return type void and no parameters will be referenced as
* "()V" while a method with the return type {@link Object} and a parameter of type boolean will
* result in "(Z)Ljava/lang/Object").
*
* @param className the enclosing class name.
* @param methodName the method name.
* @param signature the method signature.
* @param parameterName an original parameter name.
* @param parameterIndex the index of this parameter (starting with zero).
* @return a mapped method name or, if no mapping is desired, an empty optional.
*/
@NonNull
Optional getParameterName(@NonNull String className, @NonNull String methodName,
@NonNull String signature, @NonNull String parameterName, int parameterIndex);
/**
* Retrieves an inverse version of the mapping.
*
* The resulting mapping will effectively reverse the effects of this mapping (e.g. a mapping
* which remaps the method parameter at index zero from "testValue" to "a" would be inverted into
* a mapping which converts "a" to "testValue").
*
* @return an inverse mapping.
* @throws UnsupportedOperationException when the operation is not supported by this
* implementation.
*/
@NonNull
default ParameterNameMapping invert() {
throw new UnsupportedOperationException();
}
}