Class PackageInfo

java.lang.Object
org.apache.juneau.commons.reflect.PackageInfo
All Implemented Interfaces:
Annotatable

public class PackageInfo extends Object implements Annotatable
Lightweight wrapper around a Package object providing convenient access to package metadata and annotations.

This class provides a cached wrapper around Java Package objects, extending the standard API with convenient methods for accessing package annotations and metadata. Instances are cached and reused for efficiency.

Features:
  • Cached instances - package info objects are cached and reused
  • Annotation support - get annotations declared on the package
  • Convenient access - easy access to package name and metadata
  • Thread-safe - instances are immutable and safe for concurrent access
Use Cases:
  • Accessing package-level annotations
  • Working with package metadata
  • Building frameworks that need to analyze package information
Usage:

// Get PackageInfo from a class PackageInfo pi = PackageInfo.of(MyClass.class); // Get package name String name = pi.getName(); // Get annotations List<AnnotationInfo<MyAnnotation>> annotations = pi.getAnnotations(MyAnnotation.class).toList();

See Also: