View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.juneau.commons.reflect;
18  
19  /**
20   * Interface for all annotatable wrapper classes.
21   *
22   * <p>
23   * This interface provides a common type for all wrappers around Java reflection objects,
24   * allowing polymorphic handling of different annotatable types (Class, Method, Field, Constructor, Parameter, Package).
25   *
26   * <p>
27   * Implementers include:
28   * <ul>
29   * 	<li>{@link ClassInfo} - Wraps {@link Class}
30   * 	<li>{@link MethodInfo} - Wraps {@link java.lang.reflect.Method}
31   * 	<li>{@link FieldInfo} - Wraps {@link java.lang.reflect.Field}
32   * 	<li>{@link ConstructorInfo} - Wraps {@link java.lang.reflect.Constructor}
33   * 	<li>{@link ParameterInfo} - Wraps {@link java.lang.reflect.Parameter}
34   * 	<li>{@link PackageInfo} - Wraps {@link java.lang.Package}
35   * </ul>
36   */
37  public interface Annotatable {
38  
39  	/**
40  	 * Returns the type of this annotatable object.
41  	 *
42  	 * @return The type of annotatable object this represents.
43  	 */
44  	AnnotatableType getAnnotatableType();
45  
46  	/**
47  	 * Returns a human-readable label for this annotatable element.
48  	 *
49  	 * <p>
50  	 * The label format depends on the type of annotatable:
51  	 * <ul>
52  	 * 	<li>{@link AnnotatableType#CLASS_TYPE CLASS_TYPE} - Simple class name (e.g., <js>"MyClass"</js>)
53  	 * 	<li>{@link AnnotatableType#METHOD_TYPE METHOD_TYPE} - Class and method with parameter types (e.g., <js>"MyClass.myMethod(String,int)"</js>)
54  	 * 	<li>{@link AnnotatableType#FIELD_TYPE FIELD_TYPE} - Class and field name (e.g., <js>"MyClass.myField"</js>)
55  	 * 	<li>{@link AnnotatableType#CONSTRUCTOR_TYPE CONSTRUCTOR_TYPE} - Class and constructor with parameter types (e.g., <js>"MyClass.MyClass(String)"</js>)
56  	 * 	<li>{@link AnnotatableType#PARAMETER_TYPE PARAMETER_TYPE} - Class, method/constructor, and parameter index (e.g., <js>"MyClass.myMethod[0]"</js>)
57  	 * 	<li>{@link AnnotatableType#PACKAGE_TYPE PACKAGE_TYPE} - Package name (e.g., <js>"com.example.package"</js>)
58  	 * </ul>
59  	 *
60  	 * @return The human-readable label for this annotatable element.
61  	 */
62  	String getLabel();
63  }