Class TypeHierarchy

java.lang.Object
io.helidon.codegen.TypeHierarchy

public final class TypeHierarchy extends Object
Utilities for type hierarchy.
  • Method Details

    • methodSignature

      public static ElementSignature methodSignature(TypedElementInfo method)
      Create a method signature that treats method type-variable names as declaration-local aliases.
      Parameters:
      method - method element
      Returns:
      normalized method signature
    • hierarchyAnnotations

      public static List<Annotation> hierarchyAnnotations(CodegenContext ctx, TypeInfo type)
      Find all annotations on the whole type hierarchy. Adds all annotations on the provided type, and all Inherited annotations on supertype(s) and/or interface(s).
      Parameters:
      ctx - codegen context
      type - type info to process
      Returns:
      all annotations on the type and in its hierarchy
    • hierarchyAnnotations

      public static List<Annotation> hierarchyAnnotations(CodegenContext ctx, TypeInfo type, TypedElementInfo element)
      Find all annotations on the whole type hierarchy. Adds all annotations on the provided element, and all Inherited annotations on the same element from supertype(s), and/or interfaces, and/or annotations.

      Based on element type:

      If the same annotation is on multiple levels (i.e. method, super type method, and interface), it will always be used ONLY from the "closest" type - order is: this element, super type element, interface element.
      Parameters:
      ctx - codegen context
      type - type info owning the executable
      element - executable (method or constructor) element info
      Returns:
      all annotations on the type and in its hierarchy
    • hierarchyAnnotationCandidates

      public static List<List<Annotation>> hierarchyAnnotationCandidates(CodegenContext ctx, TypeInfo type, TypedElementInfo method, Set<TypeName> annotationTypes)
      Find all distinct effective occurrences of any of the annotation types on matching methods in a method's type hierarchy, grouped by the declaring method. Meta-annotations are included. Unlike hierarchyAnnotations(CodegenContext, TypeInfo, TypedElementInfo), this method does not apply annotation-type precedence between declarations. A candidate-bearing declaration excludes candidates on declarations it overrides. A declaration without matching candidates does not exclude candidates inherited from its ancestors. Candidates on unrelated hierarchy branches are retained. The provided method itself is excluded. The outer list contains distinct declaration multisets; each inner list preserves candidate order and multiplicity.
      Parameters:
      ctx - codegen context
      type - type info owning the method
      method - method element
      annotationTypes - annotation types to find
      Returns:
      distinct annotation candidates grouped by declaring method
    • hierarchyAnnotations

      public static List<Annotation> hierarchyAnnotations(CodegenContext ctx, TypeInfo type, TypedElementInfo executable, TypedElementInfo parameter, int parameterIndex)
      Annotations of a parameter, taken from the full inheritance hierarchy (super type(s), interface(s).
      Parameters:
      ctx - codegen context to obtain TypeInfo of types
      type - type info of the processed type
      executable - owner of the parameter (constructor or method)
      parameter - parameter info itself
      parameterIndex - index of the parameter within the method (as names may be wrong at runtime)
      Returns:
      list of annotations on this parameter on this type, super type(s), and interface methods it implements
    • nestedAnnotations

      public static Set<TypeName> nestedAnnotations(CodegenContext ctx, TypeInfo typeInfo)
      Annotations on the typeInfo, its methods, method parameters, and the type-use positions nested in their TypeNames.

      Type-use positions include type arguments, wildcard bounds, and array component types of the type itself, element return or field types, and parameter types.

      Parameters:
      ctx - context
      typeInfo - type info to check
      Returns:
      a set of all annotation types on any of the elements, including inherited annotations
    • typeNameAnnotations

      public static List<Annotation> typeNameAnnotations(TypeName typeName)
      Annotation instances nested inside a type name. This includes annotations declared directly on the provided type name and annotations declared on nested type arguments, wildcard bounds, and array component types.
      Parameters:
      typeName - type name to scan
      Returns:
      nested annotation instances
    • mergeTypeNameAnnotations

      public static TypeName mergeTypeNameAnnotations(TypeName typeName, TypeName sourceTypeName)
      Merge type-use annotations from a source type name into a target type name. If the type names do not have the same structure, the target type name is returned unchanged.

      Matching type names merge direct and inherited annotations on the root type, type arguments, wildcard bounds, and array component types. When both type names contain the same annotation type at a matching position, the target annotation is preserved. Formal type parameter names do not block merging.

      Parameters:
      typeName - target type name
      sourceTypeName - source type name
      Returns:
      type name with annotations merged from the source