001/**
002 * Copyright (C) 2006-2022 Talend Inc. - www.talend.com
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.talend.sdk.component.spi.parameter;
017
018import static java.util.Collections.emptyMap;
019
020import java.lang.annotation.Annotation;
021import java.lang.reflect.Type;
022import java.util.Collection;
023import java.util.Map;
024
025/**
026 * Allow to build extensions of an object parameter.
027 */
028public interface ParameterExtensionEnricher {
029
030    /**
031     * Visit all annotations of an object parameter and return for each annotation
032     * the related extensions. Note it is highly recommended even if not enforced to
033     * use a prefix by extension type.
034     *
035     * @param parameterName
036     * the name of the parameter currently visited.
037     * @param parameterType
038     * the type of the parameter currently visited.
039     * @param annotation
040     * the currently visited annotation.
041     * @return the extensions to add for this parameter.
042     */
043    Map<String, String> onParameterAnnotation(String parameterName, Type parameterType, Annotation annotation);
044
045    /**
046     * This method enables to add implicit annotations and therefore metadata on parameters based on types.
047     * Note: this method is called only once before any processing and not for each parameter.
048     *
049     * @return a mapping for types. In other words it enables to add an annotation on a type even if not explicit.
050     */
051    default Map<Type, Collection<Annotation>> getImplicitAnnotationForTypes() {
052        return emptyMap();
053    }
054}