|
| 1 | +/* |
| 2 | + * reflection-remapper |
| 3 | + * |
| 4 | + * Copyright (c) 2021-2023 Jason Penilla |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | +package xyz.jpenilla.reflectionremapper; |
| 19 | + |
| 20 | +import java.util.function.UnaryOperator; |
| 21 | +import org.checkerframework.checker.nullness.qual.NonNull; |
| 22 | +import org.checkerframework.framework.qual.DefaultQualifier; |
| 23 | + |
| 24 | +@DefaultQualifier(NonNull.class) |
| 25 | +final class ClassNamePreprocessingReflectionRemapper implements ReflectionRemapper { |
| 26 | + private final ReflectionRemapper delegate; |
| 27 | + private final UnaryOperator<String> processor; |
| 28 | + |
| 29 | + ClassNamePreprocessingReflectionRemapper( |
| 30 | + final ReflectionRemapper delegate, |
| 31 | + final UnaryOperator<String> processor |
| 32 | + ) { |
| 33 | + this.delegate = delegate; |
| 34 | + this.processor = processor; |
| 35 | + } |
| 36 | + |
| 37 | + @Override |
| 38 | + public String remapClassName(final String className) { |
| 39 | + return this.delegate.remapClassName(this.processor.apply(className)); |
| 40 | + } |
| 41 | + |
| 42 | + @Override |
| 43 | + public String remapFieldName(final Class<?> holdingClass, final String fieldName) { |
| 44 | + return this.delegate.remapFieldName(holdingClass, fieldName); |
| 45 | + } |
| 46 | + |
| 47 | + @Override |
| 48 | + public String remapMethodName(final Class<?> holdingClass, final String methodName, final Class<?>... paramTypes) { |
| 49 | + return this.delegate.remapMethodName(holdingClass, methodName, paramTypes); |
| 50 | + } |
| 51 | +} |
0 commit comments