001/** 002 * Copyright (C) 2006-2025 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.runtime.manager.reflect.parameterenricher; 017 018import static java.util.Collections.emptyMap; 019 020import java.lang.annotation.Annotation; 021import java.lang.reflect.Type; 022import java.util.HashMap; 023import java.util.Map; 024 025import org.talend.sdk.component.api.meta.Documentation; 026 027public class DocumentationParameterEnricher extends BaseParameterEnricher { 028 029 private static final String VALUE = "tcomp::documentation::value"; 030 031 private static final String TOOLTIP = "tcomp::documentation::tooltip"; 032 033 @Override 034 public Map<String, String> onParameterAnnotation(final String parameterName, final Type parameterType, 035 final Annotation annotation) { 036 if (annotation.annotationType() == Documentation.class) { 037 HashMap<String, String> parameters = new HashMap<>(); 038 Documentation doc = Documentation.class.cast(annotation); 039 parameters.put(VALUE, doc.value()); 040 if (doc.tooltip()) { 041 parameters.put(TOOLTIP, "true"); 042 } 043 return parameters; 044 } 045 return emptyMap(); 046 } 047}